Pygame Crossy Bird
Designing fun and creative gameplay with python
The goal of this project was to mashup two games that were staples of Madison and Oscar’s childhoods: flappy bird and crossy road. Photos of each can be seen below. What would be the obstacles if instead of a chicken crossing a road, the flappy bird had to navigate up the screen? Tree branches of course! With this project, we hoped to bring new life to the games we loved as children. Enter Crossy Bird, an endless game where the player avoids moving tree branch obstacles to challenge the high score. We hoped to use the pygame library to have the most advanced possible graphics and hitbox interactions. We wanted the game to be fun and lighthearted so that it is easy to play even for children. This is why the player always has 1⁄3 of the screen to use at all times, making it playable for all skill levels.
Summary of how we organized the code: Imports of os, random, and pygame come first. File paths are handled at the beginning of the code as well such as the file paths of the resources required (pictures and sounds). Next, initializations are handled of booleans and variables. Then the functions that the code is built on are all written out before we get into the Bird and Tree classes, initial setup and finally the game loop. The game loop is broken down into two pieces, the home screen which is default and the actual loop where you play actively in the game. Code’s working principles: The code’s principles are to always check the classes of the tree and bird for collisions as well as some key inputs. If the bird or trees try to go off the screen, in the birds case, the bird cannot move beyond the bounds. In the tree’s case the branches are constantly in motion so they will bounce whenever they try to go outside of the bounds. There is 1⁄3 of the screen width where the bird can exist in between the branches, and this bounces from one side of the screen to the other. If the right or left key is held down, the bird will move constantly in that direction. If the up key is pressed, the trees will move down the screen, much like the mechanics of crossy road.
Download here & install pygame in VSCode to run the game