Archive
An iPad game made in 24 hours
The challenge: build a game in 24 hours. About a week ago, two internet-friends of mine, Tom Pritchard and Frazer Grant decided they would challenge themselves to build a game in 24 hours:

Tom built a simple platformer, and Frazer built the core of a side-scrolling shmup, which he wrote about on his blog. They both tweeted their progress as they were going, using the #24hourgame hashtag, and since I follow both of them on twitter, I was inspired to take the same challenge.
I began at 11:00 on Monday, with a cup of tea—the best way to begin any project. I also decided to try using a tomato to manage my time and ensure I took enough (but not too many) breaks. I already had a basic concept in mind; a couple of weeks before I’d slapped together a prototype in UIKit to test out a possible multitouch control style for a top-down tactical shooter on the iPad, using line drawing for movement. This time around, I wanted to see how I could build a game in the style of a twin-stick shooter, but with controls designed for a touchscreen (I don’t consider the “virtual analog stick” that many iOS games use to be at all suitable for touch input).
The game would have you controlling a policeman, using various non-lethal weapons to control a crowd of unarmed student protestors. You’d use two fingers for input: one finger dragged around the screen would control movement, with your character always walking directly toward your finger. A second finger tapped on the screen would fire your current weapon. You could fire in any direction, not just the direction you were currently moving.
I knew from the beginning that I’d use cocos2d to build the game. It provided me with the basics of a game engine, giving me the code to manage sprites, sounds, and so on. It also comes bundled with Box2D, a 2D physics engine, whose API I now have quite an animosity toward—although it did most of what I needed in the end.
My progress can be seen best by searching for #24hourgame on twitter . After six hours had elapsed, I had the player input working, together with some basic enemies, who always walked directly toward the player character. But at this point, neither you nor the enemies could hurt each other. Instead, they just mobbed about you, like groupies around a rock star.
After almost four more hours, you could shoot the enemies, although they could not yet hurt you. I grabbed my tripod, set it up as short as possible on my desk, with my iPhone held to it by rubber bands, and made a short video of the game as it was so far (you can faintly hear in the background “Celebration Guns” by Stars that was playing in iTunes at the time.
I took an extra hour break to have some dinner and upload that video, and planned to do some graphics when I resumed working. It was during this break that I realised the original plan would have to change. Doing graphics or animations for humans from a top down perspective that I’d be happy with was way beyond my drawing capabilities. So instead I decided at this point that I’d make the game about a spaceship shooting other spaceships. It lacked the political overtones that the original idea had, but solved the graphics problem for me—and also the sound effects problem. You have this decision to thank for the sound effects not being me making a bunch of pain noises into my headset mic.
I began with some HUD graphics, and built a working HUD for the player’s health and ammo, and drew an enemy spaceship. Next on my list was music and sound effects. I knew if I left them until late that I’d probably never do them. I created a number of retro sound effects with Tomas Pettersson’s SFXR, specifically the free iPhone port that Chris Grassib made. That meant I was hearing the sound effects through the iPad speaker, exactly as they would sound in-game.
Music I knew would be beyond my capabilities, so I would need to find some somewhere that I could use. Someone on twitter suggested I search soundcloud.com for creative commons licenced music, and sure enough, I found something I liked within a few minutes. Three tunes by “STA$D400” Sven Hendriks: Machine Code, Argon, and Weirdometer. I couldn’t decide which of the three I liked best, so I put all three in; which one you get when playing is chosen randomly.
It was now 3am. I needed more art, so I drew a player sprite, some explosion sprites, and one sprite for a second, faster and tougher enemy. You can’t see them very well in the video below, so I’ll reproduce them here in all their programmer art glory:

I now added animation to the enemy sprites, and the animated explosion when they died. Animating sprites in Cocos2D turned out to be very unintuitive to me, and more complicated than I expected; animations are a significant part of almost every 2D game, so the fact that the framework didn’t make them trivial to incorporate took me by surprise.
I also needed a starfield for background art. Rather than drawing a new one, I instead ripped off a skybox I drew last year for one of my Team Fortress 2 maps. This skybox had lots of stars, nebulae, and bright galaxies. I cropped out a suitable 1024x768 portion, and dropped that into the scene.
There were now only four hours left. The only things remaining on my must-do list were: making the player able to die, a game menu to return to after dying, and an icon. Other things I wanted to do if there was time were the second-level enemy, scoring, and health and weapon pickups. Cocos2D has some simple menu support built in, so I quickly put together some text in Photoshop in Bank Gothic and OCR A fonts and one of Photoshop’s stock gradients, and had the menu all done in about 15 minutes. The icon took a little longer, only because I had to look up again what different size icons were required for an iPad app. Then I took another break for an hour to cook and eat breakfast.
After breakfast, I implemented scoring pretty quickly, and the second enemy was also very quick to build in, so I spent a bit of time tweaking when it would spawn and how fast it was. I now had only 45 minutes left before 11:00—which was not going to enough, I thought, to draw and code in the powerups and a second weapon. So I decided to call it done at this point. Instead, I used the time to do a second video. Since the first one had a very odd angle, this time I attached a wooden spoon to the tripod, then rubber banded the iphone to it. This meant the iphone could sit directly above the iPad, and capture it much better. You can see the result below.
I was completely stoked with what I’d managed to get done. When I started the project, I fully expected it to end up largely unplayable, with terrible art and likely no sound. Instead, the art is passable, and the sound effects and music really tie the game together.
Blog comments powered by Disqus