iPhone game prototype

I’ve finally found some time to start working on an iPhone game that I’ve been thinking about writing. I won’t give out too many details of the game itself at this point, but I thought it might be interesting to some of you if I share a few notes about my approach so far. I’m fairly new to iPhone development and certainly to iPhone game development, so this will be a learning experience that I’ll share here.

First, of course, is the concept. Despite many books on the subject, I’m not sure that there’s any magic process to coming up with an idea for a game or any other product. For me, this was just something that came to me one day. The key is taking the idea and developing something out of it, which is something I did in off times (waiting for bus, etc.). I decided that the idea held water, so I moved onto the next stage.

Second – I spent a bit of time writing down the concept that had been in my head and brainstorming other possibilities that may or may not make it into the game. What is written down still constitutes a fairly loose concept with no exact details. This is not a specification that could be handed off to an engineer to code. This is purely my ideas written down so I don’t forget them at the point that I start coding the product. In this particular instance, this amounts to 2 pages of stuff written down in my Moleskine (quad-ruled of course!). Once the game is released, I plan on releasing a scan of these notes on this blog to show you where I started and what I ended up with.

Just last week, I started coding the game. To begin, I decided to take an evolutionary approach to the implementation rather than drilling down into the details up front. I think this is the best approach given that I’ll be learning more about the iPhone platform  as I’m coding . I think this also encourages me to continuously refine the game on the fly.

So what have I been implementing so far?

Game loop: A major portion of any game is the game loop.  Essentially, this is the pulse of your game where you move objects, do collision detection, and then redraw the contents.  There are various ways to approach this, but I am currently using a NSTimer set to fire 10 times a second.  A NSTimer is not guaranteed to fire at exactly the interval I specify, but it’s close enough for now that the rest of my code is assuming the interval is constant.  If I get to a point where the frame rate becomes variable due to excessive load, then I’ll investigate other methods to make it more steady or I’ll take the actual framerate into account when calculating how to move the objects in the game.

Graphics: For now, I’m implementing the graphics using Core Graphics and just using simple drawing functions to draw into a CGContext. I have never written OpenGL code, so that would be a roadblock to me in my quest to develop the game play.

For starting with a 2D game, I think using really simple graphics to start out with is a good idea.  I want to get the gameplay going and then enhance the look over time.  With a 3D game, I’m not sure that this this approach will work quite as well (and it may not apply to all 2D games), but depending on your game you might be able to get away with drawing spheres and boxes and then enhancing the 3D models over time.

Input: I’m just using  -touchesEnded:withEvent: in my view to handle input.  I don’t think I’ll need to get more complicated than that.

So what are the next steps?  In the immediate future, I will continue refining the game play. That’s the most important thing. If the game isn’t fun and well-balanced, then it’s just not going to succeed.

After I’m happy with the game play, I will loop back to refining the graphics which are far too abstract for a final product at the moment. I generally appreciate form over function, but from the perspective of the users of a game they will want attractive graphics instead of colored blobs. I will eventually see whether I can spice them up a bit just using Core Graphics. If I can – great!  Otherwise, I may investigate whether pre-drawn sprite bitmaps are the way to go. Or, I may still have to learn how to use OpenGL in order to get the look and effects I’m looking for in order to give this a good visual polish.

At some point, I’ll have to address sound effects for the game as well. I’m not quite sure where that fits in, but I figure that I’ll start working on that while I refine the game play. I have much to learn about this area.

Hopefully some of you will find this useful. I plan on posting some more notes on my progress as my work progresses.