Table of Contents

Flappy Bird Game for Arduino

Introduction

This project is a Flappy Bird game designed to run on an Arduino Uno board with a 1.8” LCD STT735 display and a breadboard. The game is based on the popular mobile game Flappy Bird, and the objective is to navigate a bird through a series of pipes without colliding with them. This project was created by Rizan Gabriel-Adelin.

General Description

The project consists of the following components and modules:

Arduino Uno board 

1.8” LCD STT735 display

Breadboard

Buttons for controlling the bird

Buzzer 

Wiring and connections to link the components

The LCD display shows the game screen, including the bird, the pipes, and the score. The buttons are used to control the bird's movement, and the breadboard provides the necessary power and connections between the components.

Hardware Design

The hardware design includes the following:

  List of components used
  Wiring diagram and connections
  Any additional diagrams or schematics
 

List of Components: - Arduino Uno board - 1.8” LCD STT735 display - Breadboard - Button (for controlling the bird) - Jumper wires

Wiring Diagram:

Software Design

The software design includes the following:

  Description of the code used
  Libraries used
  Overview of the algorithms and structures used
 

The code was developed using the Arduino IDE, and the following libraries were used:

- Adafruit_GFX.h

- Adafruit_ST7735.h

The game code implements the following algorithms and structures:

  Game loop
  Bird movement
  Pipe generation and movement
  Scoring system
  Collision detection
  
  

Code explanation

The given code is an implementation of the Flappy Bird game for an Arduino board with an attached 1.8” TFT screen. Let's analyze the software design behind this code:

  Libraries and Definitions: The code begins by including the necessary libraries for working with the TFT screen and defining various constants for pin connections, screen dimensions, game settings, colors, and sprites.
  Setup Function: The setup() function is responsible for initializing the Arduino board and the TFT screen. It sets the required pin modes and initializes the screen using the initR() function.
  Main Loop: The loop() function is the main game loop. It calls three main functions: game_start(), game_loop(), and game_over(). These functions handle the game's different stages: start, gameplay, and game over.
  Game Loop: The game_loop() function is the core of the game. It contains a nested loop that runs the game logic and rendering at a target frame rate. It updates the game state, including the bird's position, pipe movement, collision detection, and score. It also handles user input for making the bird jump. The function uses the millis() function to control the game's frame rate and avoid blocking the loop.
  Drawing Functions: The code contains several functions for drawing different elements on the screen. For example, there are functions to draw pixels, pipes, the bird, the floor, and the grass stripes. These functions use the Adafruit GFX library and the TFT screen's methods to manipulate the pixels and colors.
  Collision Detection: The code checks for collisions between the bird and the pipes or the ground. If a collision occurs, the game over condition is triggered.
  Game Start and Game Over: The game_start() and game_over() functions handle the start and end stages of the game. They display relevant messages on the screen, wait for the user to press a button, and then proceed to the next stage.
  Game Initialization: The game_init() function initializes the game state by resetting the score, setting the initial position of the bird, generating a random seed for the pipe gap, and setting the initial position of the pipe.

Overall, the software design follows a modular approach with separate functions for different game stages and tasks. It uses the TFT screen's capabilities to draw graphics and handles user input through a button connected to a specific pin.

Code provided below

codeflappybirdrizan.txt

Results

The completed project successfully runs the Flappy Bird game on the Arduino Uno board with the 1.8” LCD STT735 display and the breadboard. Users can control the bird's movement using the buttons, and the game keeps score and displays it on the screen.

Conclusion

Overall, the Flappy Bird game project demonstrates the capabilities of the Arduino Uno board and the 1.8” LCD STT735 display when used in combination with other components. It also showcases how complex games can be programmed and run on microcontrollers like the Arduino.

Bibliography/Resources

List of resources used in the project:

  Adafruit libraries
  Arduino IDE
  1.8" LCD STT735 datasheet
  Flappy Bird game design

Export to PDF