Tuesday, August 17, 2010

Week Six / Day Two

Today's post is slightly shorter than others, on account of me being pulled away from 'the office' all afternoon for landscaping duty.

I started work on the high score lists this morning. My goal is to have Top 10 lists associated with each level that can be accessed from the level select screen. Now, I figured I would basically just be able to do my level loading in reverse, using fstream, just as I've always done for outputting to a file. Unfortunately, it isn't that simple. I have a feeling that fstream is a little too 'dirty' for the iPhone's clean application bundle, and that direct write access needs to be done via approved methods only. Therefore, today began my first major lesson in Obj-C/Cocoa since I started my app development.

As I explained in an earlier post, despite the native language of the iPhone being Obj-C (from what I can tell, being the necessary language for integration of major iPhone technologies used in non-OpenGL apps), C++ execution is perfectly acceptable. Better yet, for OpenGL development C++ is preferred for all platform independent code, specifically for the future porting of the engines. The iPhone specific code for my game is only about 200 lines or so. Porting to something such as the android would require some tuning for handling the differences in touches between the two devices, and appropriately controlling the instantiation of each engine component. Other than that, it wouldn't be all that difficult. There were tutorials I had read that seem to foster a much more iPhone-centric view, but I think the benefits of an interface controlled engine are fairly obvious.

The point of all this was that I needed to learn some iPhone specific data management. While I was trying to avoid this, what I needed to learn was extremely simple. There are a few methods for going about data management. One I would like to learn eventually is SQLite, handling app data in a database style fashion. Not only does this lend to a much more powerful data/data-manipulation connection it would be a good way for me to get some database experience, as I've currently got zilch. However, what I am using is a data type known as NSUserDefaults. NSUserDefaults, from my understanding, is sort of an open book ready to filled with whatever values you want, and a key associated with said values (C++ Dictionary?). As the name describes they are generally associated with the Defaults of a program, such as user name and preferences, however everyone on the internet seems to suggest using them when implementing a high score list. I suppose I can't argue with that. So tonight I started to get a bit of a basic framework in for handling the saving and restoring of an NSUserDefault within my game. Since it is an OpenGL application is has a few modifications from the default app structure. It takes a few hops to get the data down deep enough to where I need it, but not a big deal really.

Tomorrow's work will begin with getting more than a string moved around. Apparently arrays are just as easy as strings (NSArray and NSString respectively), so an array of a levels scores along with a simple key should do the trick. Things don't always go as easily as you think they will, but with this step in the implementation they seem to have, so I'm counting on it continuing. Tomorrow should hold some more comprehensive updates, so stay posted.

1 comment:

  1. I take it back. Even when I say I'm not going to talk as much, I do.

    ReplyDelete