Angry Balls

Overview

I created a simple game called Angry Balls for the Mbed ARM-based platform. The setup for the game features a uLCD-144-G2 screen for displaying graphics, an MPR121 capacitive touch keypad from Sparkfun for user controls, and a PCB-mountable simple speaker from Sparkfun with a 2N3904 amplifier for sound effects. The game also features the display of an image on the LCD that is loaded from an SD card.

How to Play

Here is a snapshot of the game being played:

/media/uploads/gmiles3/gameshot.jpg

Solid Green box => USER

Solid Grey box => PAYLOAD

Hollow White box => Start and reset location for PAYLOAD

Hollow Blue box => PORTAL

Solid Red ball => ANGRY BALL

The object of the game is to control the USER via the touch keypad to push the PAYLOAD into the PORTAL to score a point. Upon scoring, the PORTAL will change locations. If the ANGRY BALL, which is furiously flying around the room, comes into contact with the PAYLOAD then the game is over. The USER is impervious to the ANGRY BALL. With this in mind, the USER can deflect the ANGRY BALL away from the PORTAL. If the USER finds him/herself in a tight situation, the PAYLOAD can be pushed into the wall, at which point the PAYLOAD will respawn (from the hollow white box). Be wary you don't force the PAYLOAD to reset whilst the ANGRY BALL is making a bee-line for the reset area. The USER moves slower while pushing the PAYLOAD due to the PAYLOAD's "weight".

Note: The PORTAL is called the PORTAL because I couldn't think of a good name. It doesn't actually teleport the PAYLOAD like you think it would. In fact, the walls themselves are actually the portals in this case.

The player controls the USER with the keys on the touch pad. The 3 Key is the "Action" key, used for starting, pausing, placing the ball, etc.

Here are the touch pad key bindings:

/media/uploads/gmiles3/keypad2.jpg

Demo

Here is a video of the game being played (note how angry that ball is... pretty scary):

Hardware Setup

Here is a schematic of the devices used:

/media/uploads/gmiles3/schem.jpg

Here are all the pin connections to the Mbed microcontroller:

Device PinMbed Pin
LCD +5VVU
LCD GNDGND
LCD RXp9
LCD TXp10
LCD RESp11
2N3904 Bp21
Keypad VCCVCC
Keypad GNDGND
Keypad IRQp26
Keypad SCLp27
Keypad SDAp28

Remember

Remember to place I2C pullups on the SDA and SCL lines for the keypad. I have used 4.7K ohm resistors. Make sure they are not in-series.

Remember to supply +5V to the LCD via the VU pin on the Mbed. All other power pins will be +3.3V except this one.

Code

Here is the code for the game:

Import programangryballs

A simple game


Please log in to post comments.