Monday, March 21, 2011

Happy Pepe is now happier

Pepe is very happy today. It has climbed to Number 2 spot in the 'Educational Games' category in iTunes Turkish store.

Saturday, March 19, 2011

Happy Pepe: An iPhone Game designed to teach math and improve memory

I have a son (Emir) in 4th grade and a daughter (Selin) in 3rd. Neither one of them enjoy doing homework. This is not very surprising or upsetting for me as I still remember how much I hated it myself.

I sometimes try to help them out with their math homework and usually get frustrated quite easily. Just recently I found myself telling my daughter one needs to memorize the multiplication table. That insanity didn't last for too long fortunately as I realized the absurdity of what I was asking. I realize one needs to know how to multiply at least single digit numbers but with which method a child needs to get there?

One can start with say 2s and recite outloud 2x1 is two, 2x2 is four, and so on..Up until 5s, that works but it gets exponentially harder once you hit 6s. You then resort to rimes, etc.

I thought another and more fun way would be to embed multiplication and addition questions inside an iPhone game application. And I decided to write one...

I am a software engineer so I know how to code but my experience has been with client/server systems, financial systems, web applications, etc. I had never written a single game before. But the game I wanted to write didn't need to be a 3D extravaganza either.

I had heard and read about Cocos2D (http://www.cocos2d-iphone.org/) game framework before. But then when I was googling for other frameworks I ran into Jonathan Beebe's blog post (http://jonbeebe.tumblr.com/post/1119939987/corona-sdk-review) about Corona SDK by AnscaMobile (http://www.anscamobile.com/corona/). I started reading about it and it immediately felt right which is a feeling coders are familiar with.

I had to learn a new language, Lua, in order to start coding with Corona. That didn't turn out to be a problem as I enjoy experimenting with new languages and it's not a cryptic language with a steep learning curve.

Corona download comes with great samples, and those helped me out a lot. Both in learning Lua and understanding the components of a game.

I first consulted with my kids about the story of the game. We picked up the hero (a penguin) and decided that the aim of the game would be for Pepe the penguin to try to catch fish falling from the sky. Some fish would get Pepe points, and some others, like a shark, a killer whale, would cause him points.

For the 'teaching math' part of the game, we decided to display for a short period multiplication and addition questions such as '3x9=?', '14+9=?', etc in the middle of the screen and then fade the question so that the player would need to calculate the answer and remember it. Then along with fish, we would start dropping numbers from the sky and Pepe would get points if he were to catch the correct answer number. Catching the wrong numbers would cause him big points...

I started writing the code in the evening on March 3rd. My first challenge was to create multiple screens: one to display the menu, another one where the actual game happens, another one for the settings, etc. Corona samples really helped a lot with this. I read lots of their code and settled on an approach.

The next issue was to figure out how to drop objects from the sky in a real-life manner. It turns out Corona comes bundled with a physics engine: Box2d (http://www.box2d.org/). And it's funny how straightforward it's to use it:

physics.addBody(hero, "dynamic", {density=3.0, friction = 0.5, bounce=0.0})

There is a comfort point for a coder when reached makes him able to achieve almost anything using a framework. Getting to that point is very quick with Corona. Corona is to game programming what Ruby on Rails is to web development.

Once I got to that 'comfort' point, I was able to advance quickly and finished the skeleton of the game. I consulted with my kids at all times about the look and rules of the game and they gave me plenty of valuable feedback.

Then came the hard part: graphics! Man do I suck at graphics! Even trying to come up with a background and foreground color combination is a task enough to give me nightmares at night. And I didn't want to spend a fortune nor waste time trying to find a graphics guy to come up with icons, images, etc. So I started searching for the images on the net. Of course I had to watch out for the licenses as well.

Next came the sound problem. Playing sounds inside the program couldn't be easier:

local sound = audio.loadSound( "your sound file")
audio.play(sound)


but finding background music, or drop sounds were the tough ones.

At the very end, we decided to name the game HAPPY PEPE. Here are some of the screenshots taken during game play:






On March 10th, I was done. Emir and Selin tested the app thoroughly and then we submitted to Apple for approval.

And finally on March 18th, the approval came from Apple.

You can find Happy Pepe at:




And of course, big thanks to Corona...

Mobile Development Showcase