Thursday, August 11, 2011

Open Source Game: Simple Ball Bouncing Game

Based on YouTube video http://www.youtube.com/watch?v=iGwZoowB-6Y&feature=related by TheEagle1100, I learned quite a lot of new things and created this new simple ball bouncing game: the timer, the game state, the way to move the balls, move the platform down, setup the scores, ...etc.

As shown in screen dump below, there's a few balls bouncing up and down, getting scores on every bounce. When the balls bounced above top 1/4 of the screen, the green platforms moved down and more new ones appeared at the top.


Due to the problem with the NIB-less template I used before - which wouldn't rotate properly, I now use an "empty" NIB, finally it rotates as expected this time.

Instead of 1 single ball and 5 hard coded IBOutlet in the YouTube video, in my project both the platforms and balls are defined using arrays, and you can freely adjust the parameters to get more platforms or/and balls. The NIB was left empty and all UIImageView, UIButton, UILabel objects were added by code.

In the YouTube video (not this one but part 8 or 9? can't remember), TheEagle1100 also demonstrated how to setup the code to control the ball movement in the real device by tilting it around. Unfortunately I only have the simulator, so that part wasn't included.

I also removed the menu and changed the ending part with a button. Hope you find it interesting.


Source to double simple game

0 comments:

Post a Comment