Crappy Bird

I design a game that can be played on my single button board.

Updated: December 2, 2015

Personal Project Goals

One thing that I've always wanted to do, but haven't had the chops for, is to make custom video game controllers. In an alternate universe, my final project would be a game controller case for my phone. For this class, though, building a simplified version of this as a week project, I figured, would suffice. I love video games, so this was also a chance to do something games-related in this course.

Read More / Hide

There were two goals here. One was that I had enough things on my plate, final-project-wise for things I had to create for next week, so I wanted to reuse an old board. Second, since I already do a lot of programming, I wanted to learn a new tool - not squeak by with something I already knew. Originally, I had intended to learn Processing, because I've seen how powerful it is for rapid prototyping. However, my fear was that Processing would (naturally) be very similar to Arduino - a paradigm and collection of excellent API calls which work great in isolation and become incredibly messy when you want to integrate it with tools outside of Processing/Arduino. Instead, I decided to learn another tool I'd been meaning to learn for years for rapid prototyping of games - PyGame.


I decided to use my board from Electronics Design week as my input board. Fibonacci blinking was boring anyway! But, what could I do with just a single button input? What kind of interesting game could I make? Immediately, my mind jumped to Flappy Bird. I decided I would make my own, quickly prototyped Flappy Bird-type game. And thus, Crappy Bird was formed.

crappy bird

Read More / Hide

In this game, the player has control of the blue square. Holding a button accelerates the blue square up until it reaches a maximum velocity. Removing a button lets it fall back down via gravity. The orange blocks move to the left at a constant speed. Their positions are randomly generated. As of now, there is nothing to guarantee that the level is feasible. We'll file that under future work :-).

Coding the game with pygame was remarkably easy - and done in fewer than 150 lines. It was incredible; I expected to be up all night working on a game, but I was done in fewer than 2 hours. I remember reading a few years ago about a few guys who created 50 game prototypes in 50 days (or something like that). Now I understand why. You take a template, create your main game loop, and then - you're practically done. Collision detection is built in. Drawing objects is a single line. I formalized the game as six steps, and then just had to write six functions. The code for crappy bird can be found here.

Next came interfacing with hardware. I was using already fabricated hardware, and I thought this would allow me to focus on the software for this week. I should have known it wouldn't be so easy. After I originally fabricated my board, Neil warned the class that those of us who created FTDI header pads without extending the copper would have rather fragile joints - a small amount of torque would peel the header right off! I dodged that bullet for a few weeks, but I today I got a little too rough with it, and, well, my header peeled off. This also peeled off a lot of my copper traces. I tried to repair it by cutting and soldering adhesive copper bits, but it's too high precision to do without vinyl cutting, and setting up the vinyl cutter for a small repair job is a lot of overhead. Further, there's an inherent registration problem between the old bits and the new bits that make it a delicate operation with plenty of room for error, and I found the copper doesn't adhere well to the PCB backing anyway. Thus, I had to fabricate a new board from scratch here.

Once this was one, I was able to program up my board. I based it off the and ATTiny45 example, changing the appropriate bits to fit my needs (moving the python polling to a background thread, changing the c code to always report the button state rather than implement a state machine, and making it work for the ATTiny44 rather than the 45). The code can be found here.

The result? A one button Flappy Bird game with a hardware controller! A video of it in action can be seen below.

Current Issues

Of course, the board I originally created for Electronics Design week has an LED. I wanted to use the LED for this week, and have it light up or turn off depending on something in the game state. Of course this would not really add to the game, but it would demonstrate that I know how to send information from pyserial back to the device. Unfortunately, I'm yet to figure out how to do this in software. The ATTiny44 connection is duplexed, so this should work, but currently I am trying to work out some bugs. I'd like to make a light turn on on game start and turn off on a game loss.