Oswald Touch is an iPhone game I created on the iPhoneDevCamp 2008. In this blog, I’ll describe the 17 hours non-stop coding it took creating the Oswald Touch. Note that this blog is a cross post from iphone.devcamp.dk.
Motivation and goals
I spent the weeks before iPhoneDevCamp thinking about what application I should program on the camp. I was looking for something that used the as little as possible from the rich API the SDK provide, since I didn’t have any experience with development for iPhones (or Mac).
Thanks to a commercial of the Danish TV-2’s 20 years anniversary, I remembered a game about the ice-bear Oswald jumping on ice and whales. The game was broadcasted on TV-2, where the users controlled the bear using their phone.
So I decided to create an Oswald remake for the iPhone. I found some suitable screenshots for the application at http://www.lemon64.com/games/details.php?ID=2548 . I estimated that I could program the game myself on the camp, so I decided to work alone on the project.
The following diary is based on the plan I made as the first thing after I arrived to iPhoneDevCamp. I figured that I would be unable to plan anything in the middle of the night … but might be able to stick to a plan.
- 19:00 Setup, Chit-chat, pizza, Tech talk, let the coding begin….
- 00:00 Create a splash screen. I spent the first 3 hours trying to figure out why the low-level function CGContextDrawImage flipped the image vertically. In the end I gave up, when found out that the higher level object UIImage could also draw itself to a CGContext correctly.
- 01:00 Creating a background. Started with some water texture, but decided to keep the original blue Oswald water color
- 01:30 Extract all game graphics from screenshots (ice, whale, Oswald, Oswaldine).
- 02:30 Create a game model class. Basically the model is an array for each column of objects and an offset to make the object move. The characters both has a x and y coordinate that represents their location (in the array)
- 03:00 Let the view draw the model
- 04:00 Implement touch events to move the characters.
- 06:00 Add a new thread that updated the model so the ice and the whales moved.
- 08:00 Added some logic (two players cannot be on same location) and fixed some bugs.
- 10:00 Added game over screen
- 11:00 Brunch and presentation
- 11:30 Wow … I won … I bit too tired to realize it.
- Model-View-Controller pattern
- 2 views
- 1 controller
- 1 model
- Views: UIView
- Delegates touch events to controller
- Overwrites drawRect to do the actual drawing
- Mapping mouse events to model updates (movement of Oswalds)
- Location of game objects
- Logic (disallow movement of water, out of bounds, only one bear per location)
- Game thread – updates the location of game objects
- Memory management
- Load everything on startup (and hope it fits in memory)
- After startup the game does not allocate any new objects, so there shouldn’t be any memory leaks.
What a great way to end the week. I really enjoyed my first experience with the iPhone SDK, it’s a great platform with a better and more complete SDK than any other handheld device I have worked with.
And I want to thank the organizers for all the work they put in it. Great job.
I hope to see you all for the iPhoneDevCamp 09!
Small video wma
Small video mov