Buildy Dodge is available for free here.
A Video Description of the game can be found here.
Buildy Dodge is an arcade-style game I designed for CSCI 1310 at CU Boulder. The premise is as follows: You are a rectangle who is being bombarded with missiles. Your job, of course, is to dodge them. This can be done in one of two ways, you can build blocks to stop the missiles, or you can simply try to move out of their way. Unfortunately for you, the missiles destroy any block they touch and they progressively get faster. You will need to keep building blocks to keep from falling to your death. You can build blocks anywhere in the black area.
If you fall, you lose a life; if you are hit by a missile, you lose a life. You start with twenty lives.
The core of this game is a dictionary of each of the following blocks:
If the key “A1” in the dictionary corresponds to a value of 1, then a block exists there. Otherwise, there is no block there. A function takes this dictionary and displays all the blocks that should be present. A series of if statements create boundaries around these blocks while they exist.
The code for this program gets a little messy because every block needs to be treated like a wall,
and since walls are constantly being built and destroyed, it is easy to find the character inside one or more walls at any time. To address this, each block’s coordinates are recorded in dictionaries. If the program detects that a motion would cause the character to touch a block, it uses these dictionaries, as well as the dimensions of the character and the block, to determine what side of the block the character is on. If the character tries to move into a block from the side, the x coordinate of the character will not update. If the character tries to move into the block from the top or bottom, the y coordinate of the component is moved upward and all other factors of y movement are ignored. This has the effect of always lifting the character upwards if it becomes stuck inside a block.
The character falls at a constant speed of “gravity.” The motion of the character is determined by pygame inputs (Arrow Keys and Spacebar). Once the player loses all their lives, a screen displays the final points and “GAME OVER.” One aesthetically pleasing feature is that the game continues to play in the background; although, the player cannot build blocks and the score does not increase.
How to play:
Starting the game
- If you do not have python downloaded, follow the instructions below:
- This game runs on python and requires pygame to be downloaded. Type “sudo apt-get install python-pygame” into the terminal and hit ENTER. If this returns nothing, pygame has been successfully installed.
- Download and unzip Buildy Dodge
- Navigate to the directory where you unzipped the Buildy Dodge folder.
- Start the game by typing “python BuildyDodge.py” into the terminal and hit ENTER
- Use the arrow keys to move. Up will make the character jump. It will also allow you to climb up any existing blocks.
- Use spacebar to build a block . You will be moved up above the block
- You get one point for every missile that does not hit you, including those which hit blocks.