How kenth356/flappy-bird-clone works
Project type and purpose
• This is a standalone 2D game (a Flappy Bird clone) written in C++ with an assets folder for audio, backgrounds, fonts, and skins.
• There is no client–server split or database; it’s a desktop/mobile game engine with resource loading, game logic, rendering, and audio subsystems.
File structure
• Top-level source files
• Flop.cpp – likely contains main() and the game loop
• BIRD.cpp / BIRD.h – the player‐controlled bird entity
• PIPES.cpp / PIPES.h – the obstacle entities
• VARS.cpp / VARS.h – global constants or configuration
• ASSETS directory
• AUDIO – sound effects & music
• BACKGROUNDS / SKINS – graphical textures for backgrounds, birds, pipes
README
• Only contains the title "Flappy-Bird-Clone"
• No architectural hints, so we infer the standard game-engine structure.
Main components
a. Game Loop
– Central orchestrator: calls input handling, game logic update, rendering, and audio updates each frame.
b. Input Handler
– Captures key/touch events (spacebar or tap).
c. Game State Manager
– Maintains states: Start, Playing, Game Over, Winner.
– Holds references to Bird, Pipes, Score, and triggers transitions.
d. Entities
– Bird: position, velocity, sprite, flap logic.
e. Collision Detector
– Checks Bird vs. Pipes and Bird vs. ground/top bounds.
f. Asset Manager
– Loads textures (backgrounds, sprites), fonts, and audio files at startup.
g. Rendering Engine
– Draws background, pipes, bird, score overlays every frame.
h. Audio Engine
– Plays flap, point, collision, game over, and background music.
i. Configuration/Globals
– VARS: gravity, flap force, pipe gap/distance, screen dimensions.
Relationships and interactions
• Game Loop → Input Handler → Game State Manager → Entity Update Logic (Bird, Pipes)
• Game Loop → Collision Detector → Game State Manager
• Game Loop → Rendering Engine (reads Entities, Assets)
• Game Loop → Audio Engine (triggers sounds/events)
• Asset Manager feeds textures/sounds into Rendering/Audio Engines at initialization.
Architectural patterns & design principles
• Single-threaded, frame‐based loop (common in simple games)
• Separation of concerns:
• Input vs. Logic vs. Rendering vs. Audio
• Entity classes (Bird, Pipes) encapsulate their own data & behavior
• Resource management centralized in Asset Manager
• State pattern (or simple enum-driven switch) for game states