views:

1693

answers:

4
+2  Q: 

Frogger for iPhone

Most of my programming experience has either been using forms (Windows Forms, or ASP.NET) or small embedded projects interfacing hardware. Recently I began going through some tutorials for iPhone development. I'm interested in learning Objective-C and the iPhone sdk.

I wanted to make a small frogger-like game to help me learn but I've never really ventured into game development. I would have four buttons (Up, Down, Left, Right) and was curious how to go about the navigation. Would it be smart to make a big grid (matrix) and use that to navigate around the screen? Eventually it'd be nice to use OpenGL but I'm nowhere ready to go into that area yet.

Thanks for any input.

+2  A: 

You'll need to derive a subclass of UIView and override the keyDown: method in order to get keypresses. There's an NSTimer class, that's good for doing periodic updates, and UIImage, for loading and displaying bitmaps on the screen.

You can probably just use (x,y) coordinates for all the objects you'll draw, rather than having an explicit grid. You can then update the positions of the objects at regular intervals.

Mark Bessey
+1  A: 

Lights Off is a relatively simple iPhone game that was built without using OpenGL. The source has been released and would probably give you a decent idea of how to go about getting started.

More info here: http://furbo.org/2008/09/19/lights-off/

Lounges
+2  A: 

Here is a simple tutorial on Cocoa2D, what you would use to make a 2D game.

There is also a tutorial on touch detection here by the one of the authors of the Coca2D tutorial.

Also, the source-code to a complete, working game could be useful - there are some open-source, complete games listed on my question "Are there any Open-source iPhone applications around?"

dbr
+1  A: 

I was in your situation, before starting to build a 2D puzzle game, I looked into quartz and opengl, and I ended up going the opengl way. It's a bit more complicated, but it's far more flexible. Performance-wise, You probably don't need it to build a frogger clone, but if you ever need a boost, like many shapes at once, it will be up to the task. What I did was wrapping up opengl code in my own methods, so I didn't need to think too much about it. After I had more experience with it, I started calling it directly where I wanted to optimize.

To get started quickly you can use the opengl template on xcode. You can also use it to see how the NSTimer is set up. If you need textures, check the Texture2D class in the apple CrashLanding sample app.

This website is a great resource to grasp the basic concepts of opengl es, like the vertex and color arrays: http://www.zeuscmd.com/tutorials/opengles/index.php

As for the grid you mentioned, read about tile-based engines. There's many tutorials on the subject. It's definitely a good idea for frogger.

Steph Thirion