Thursday, August 19, 2010

Week Six / Day Four

Whew, crazy day.

First of all, I didn't work all day, as my Dad and I did lunch and a movie this afternoon. Nevertheless, I still managed to get quite a bit done. Top Score lists are consistant across game sessions now. It turns out my understanding of how NSObjects work was incorrect. Every NS* type is a pointer, and I knew this, but for some reason it just hadn't clicked with me. Therefore, I was writing an array, changing it, and then writing the next set of values to it. However, when I stored this array I was only storing the pointer, therefore changing the values I had just set previously. But once I got that cleared up I tidied a few other parts of the NSUserDefault methods up and got it running smoothly.

The second major accomplishment of the day was getting the player name entry screen implemented, which you can see down at the bottom of this post. I had originally set it up so that you entered the name entry screen just prior to level selection, but I realized this was just too tedious. iPhone games (especially ones such as mine), are meant to be quick to start and play. Having to enter your initials every time you play the game would lengthen the amount of time before the player can start playing, and that just won't do. What I've done instead is displayed the name on the level select screen where the player can edit it at their will. Also, similar to the high score list a player's initials will last across game sessions, so once the user enters their initials once (assuming no one changes their default name), they won't have to change it again. Mmm, convenience.

I had a bit of a heart stopper today. While I was implementing the initial entry screen, I was getting very odd memory errors. I narrowed it down to being a problem with building the sets of buttons parameters for registering a touch on the screen. However, the debugger wasn't telling me this, I was just getting more general malloc errors. In my mind this meant one thing; low memory. Needless to say I went on a mini optimizing spree. It turns out that I was still generating a bunch of textures that I wasn't using at the moment, so clearing them out freed some resources. I also moved the methods for building the parameters for all the buttons so they were only in memory when they were needed (that is, built and cleared in real time rather than just built once at initialization) without any noticeable slowdown. However, even after all this, the error was still there. Worse, it was reacting differently on the simulator and the device, which always makes things twice as difficult. After taking a breather and coming back, I realized I wasn't setting an iterator to the successive vector before moving through it; in English, that means a heart attack over one line of code. Therefore, something I would expect to give me a specific out of bounds error tied to a certain method (often times down to a specific line of code) instead gave me cryptic memory allocation errors. Frustrating, but just another lesson in never assuming anything from what errors you receive, because no two errors are truly the same.

That about wraps it up for today. I'm not too sure what I'll work on tomorrow, honestly. Perhaps I should start looking into sound? I've got most of the 'stitching' for the core of the game completed, so it's time to do some tidy work as well. For instance, the level select screen is a mess, and I have some ideas about making the interface flow a little better. If not sound, than perhaps starting some preliminary work for the level builder so I can actually start turning this into a real game! In the mean time, Good Night, and Good Luck.

No comments:

Post a Comment