www.sjwaller.com

Projects » iPhone

1st iPhone app – Part 3 – 3D Shoot ‘Em UpMarch 15th, 2010

Now I’m “in-between” jobs … I’ve had a few days to put some effort into iPhone development again … and here’s a video of where things stand.

As you can see things have progressed somewhat from the previous installment and it is starting to really look like a playable game. The major new code includes a SkyBox for rendering the backdrop, enemy cubes to shoot at, collision detection to register a hit and also MP3 playback and SFX.

SkyBox

The SkyBox routine is basically as simple as rendering a large cube around the whole scene and applying a texture on the inside. This gives the effect of a nice backdrop whichever way you turn. For the time-being, I’ve used a jpg that I found on t’interwebs that was pre-prepared for use as a SkyBox in CounterStrike.

Collision Detection

There are a total of 10 enemy cubes rendered at any one time. Enemies are randomly scattered in front of you and gradually make there way toward you. If you shoot them, a SFX is played, your score increases by 10 and an explosion routine ensues. Once the explosion is over, the enemy re-spawns randomly somewhere in front of you and again makes it’s way toward you. The explosion routine is basically 10 small cubes which get assigned a random direction vector from the point of impact. These ‘explode’ away for about 100 frames. Well, I think it’s pretty sweet effect! If the enemy gets too close to you a red flash appears on the screen, your score is lowered by 100 and the enemy re-spawns.

The collision detection routine is a basic Bounding Sphere as described here: http://www.gamedev.net/reference/articles/article1234.asp. As the bullets move pretty fast, I used the advanced version to pick up collisions if say a bullet passes ‘through’ the bounding sphere over two frames.

Sound

For MP3 playback, I used the audio queue service in the Apple AudioKit framework. At the moment, I start my favourite Rob Hubbard C64 ‘Lightforce’ MP3 playing in the game initialization method. The SFX comprise and explosion and a gunshot wavefile I downloaded from www.freesound.org. These are played using the SoundEffect class found in the BubbleLevel SDK example.

Next time …

My next installment should see a variety of enemies with different routines such as weeving about and firing back, a shield to deflect enemy fire, a level system and possibly some kind of terrain (I’m working on a simple heightmap terrain routine but didn’t get it looking satisfactory for this update).

Anyway -- sorry about the hectic sound if you listened to the video on headphones … oh and I gave the game a work-in-progress title of … “Last Stand”  but it seems there’s already an iPod touch game called that … anyone have any other ideas feel free to leave a comment?

Leave a Reply