Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2023:apredescu:flappybirdproject [2023/05/08 10:09]
gabriel.rizan
pm:prj2023:apredescu:flappybirdproject [2023/05/28 21:33] (current)
gabriel.rizan
Line 9: Line 9:
 The project consists of the following components and modules: The project consists of the following components and modules:
  
-Arduino Uno board+  ​Arduino Uno board  
 + 
 +{{:​pm:​prj2023:​apredescu:​arduino-uno-r3.png?​200|}} 
 +  
 +  1.8" LCD STT735 display
   ​   ​
-  ​{{:​pm:​prj2023:​apredescu:​arduino-uno.png?600|}}+ 
 +{{:​pm:​prj2023:​apredescu:​tftunorizan.jpg?200|}}
   ​   ​
-- 1.8" LCD STT735 display 
   ​   ​
-  ​{{:​pm:​prj2023:​apredescu:​icon.png?​600|}}+  ​Breadboard
   ​   ​
-- Breadboard +  ​ 
-  +{{:​pm:​prj2023:​apredescu:​breadboardrizan.png?​200|}}
-  ​{{:​pm:​prj2023:​apredescu:​breadboardrizan.png?​200|}}+
  
-- Buttons for controlling the bird 
  
 +  Buttons for controlling the bird
 +{{:​pm:​prj2023:​apredescu:​pushbutton.jpeg?​200|}}  ​
  
 +  ​
 +  Buzzer ​
 +{{:​pm:​prj2023:​apredescu:​andrei_mihai_alexandru_1221a-_buzzer.png?​200|}}  ​
 + 
 +
 + ​Wiring and connections to link the components
  
-- Wiring and connections to link the components+{{:​pm:​prj2023:​apredescu:​wires_adina_amzarescu.png?​200|}}
  
  
Line 51: Line 61:
 Wiring Diagram: Wiring Diagram:
  
-{{:​pm:​prj2023:​apredescu:​sketch.png?200|}}+{{:​pm:​prj2023:​apredescu:​schemarizan.png?800|}}
  
  
Line 78: Line 88:
     Scoring system     Scoring system
     Collision detection     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 
 + 
 + 
 +{{:​pm:​prj2023:​apredescu:​codeflappybirdrizan.txt|}}
  
 ===== Results ===== ===== Results =====
Line 87: Line 124:
  
 {{:​pm:​prj2023:​alex_predescu:​icon.png?​200|}} {{:​pm:​prj2023:​alex_predescu:​icon.png?​200|}}
 +
 +{{:​pm:​prj2023:​apredescu:​showcase.jpg?​200|}}
 +
 +{{:​pm:​prj2023:​apredescu:​whatsapp_image_2023-05-28_at_17.06.22.jpg?​200|}}
 +
 +{{:​pm:​prj2023:​apredescu:​whatsapp_image_2023-05-28_at_17.06.21.jpg?​200|}}
  
 ===== Conclusion ===== ===== Conclusion =====
pm/prj2023/apredescu/flappybirdproject.1683529751.txt.gz · Last modified: 2023/05/08 10:09 by gabriel.rizan
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0