The Flappy Bird Dare: A Tutorial on SpriteKit and Programming for iPhone

I stuck my foot in my mouth.
I’m now chewing vigorously and that is why you are reading this.
For those who never heard of Flappy Bird, it was the game sensation nobody expected. It was a game that was very simple: a little bird moves up if you tap the screen, and falls due to gravity if you don’t. The game play is also simple: fly between two pipes without touching them and get a point. If you touch the pies or the ground, the game ends. While that seems easy, game play is very difficult.
The programming world was outraged when this jumped into #1 slot in iTunes and the developer began making $50,000 a day, far more than much slicker games with intensely realistic graphics. Then suddenly, the author pulled it from the stores. There was controversy. Not only was it simple, the game was put together with graphics that went out of style in before the Gameboy. How did such a cheap game added to the store almost a year ago suddenly have such a meteoric rise? Apple’s App Store and Google Play hunkered down for an invasion of clones to the now defunct Flappy Bird, and the author now says he pulled it because it was so addictive.
I was explaining the Flappy Bird controversy to a Friend. I claimed I could, actually anyone could, write Flappy Bird in a week. My friend dared me to try, and so I had ended up with a week-long challenge — write a Flappy bird clone in a week then get it into the App store, with a variation or two.
Thus Slippy Flippy Penguin was born. If it gets into the App Store is another thing.
I didn’t want to write a clone – I prefer originality, like the game I’ve been working months to finish and is still under development. Besides Apple throwing it into a garbage heap in a second with the rest of the cheap knockoffs of the originall, I want to teach how to write games and how to program. I’m an educator at heart. Apple also last year made game programming a lot easier by introducing Sprite Kit to Xcode, the suite of programs used to write apps for iPhone and iPad. So a bigger challenge looms — can anyone write not just a clone but any game similar within a week’s time? If you have a Mac and can load Xcode, you are certainly welcome to follow along and write your own game. If you don’t, you may learn something too about a lot of what goes on behind the touchscreen of your iPhone.
The game itself is simple, which is what makes it such a great educational tool. I’m also going to keep myself extremely simple to follow. It means we can learn programming easily. But I will make a disclaimer here about my teaching style, which is different from almost every other tutorial I have ever read: I will intentionally write buggy code. I will then go through the process of fixing it. That happens so rarely and debugging is one of the most important programming (and arguably life) skills one can have.
How I approach the game design (indeed all design) is to break it into the various parts, far before I start coding. Imagine we have a scene in a play or movie. As a director I have the following things I need to use:

  1. Actors
  2. The stage
  3. The script

I can break that down a little further:

  1. Actors
    1. The hero/heroine
    2. The bad guys
    3. The bit players
  2.   The stage
    1. Acting space
    2. Backgrounds and scenery
    3. Stage entrances and exits
  3. The script

Games organize themselves a lot like this, with a few additions. For example in my game:

  1. Actors
    1. Player’s Character or Characters — a Penguin
    2. Obstacles or Opponents — Ice blocks and walls.
    3. Other actors — changes in gravity
  2. The stage
    1. Foreground action penguins and ice blocks
    2. Background (may also be in action) – icicles
    3. Informational displays score — one point for passing an obstacle high score — a remembered high score. Lives — this game you only get one life.
    4. Places for characters to enter and exit — left and right
  3. The script
    1. How characters move — penguin has controlled movement up or down to some extent. Penguin is affected by gravity and collisions with objects. Ice blocks will move from right to left, giving illusion of Penguin sliding scenery will also move right to left how characters interact collision with ice pushes penguin back, or possibly ricochet’s out of control.
    2. What starts the game – touch to start what ends it — penguin falls into the water or off the back of the ice flow. (May also be water)
    3. How to start the game again.

Note I didn’t answer all the questions, but I try to get a much as I can before I start. Once I have that much as a framework, I can then begin to program.

In our next entry, we will open up Xcode and set up our main character: a penguin that suspiciously looks like a spaceship.

Editor’s note: I moved the adventure of wirting this app to my programming blog for all the information click over to the SlippyFlippy penguin page at including links to the finished game.

Trainer, App developer. Author. Artist. Proprietor of and Host of Slice of App Pie Show

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: