How fm39hz/flappybirdgame works
Project type and purpose
• This is a single‐player 2D game (Flappy Bird clone) built on the Godot engine, written in C#.
• It follows an Entity-Component-System (ECS) style, with MVVM and Domain-Driven Design influences.
• It uses Godot scenes (*.tscn) for UI and game world, and C# classes for logic.
Main architectural components
a. Godot Engine / Game Loop
• The underlying engine that drives rendering, input polling, physics, and the scene tree.
b. Game Container & Scenes
• GameContainer.tscn (and other *.tscn nodes) – orchestrates scene hierarchy.
• Main.tscn – initial entry point.
c. ECS Core
• EntityTable (central registry for all entities)
• Entities – containers for Components (src/Entity/*, src/Game/Creature/*, src/Game/Environment/*).
• Components (src/Component/*) – discrete behaviors (Movement, Animation, Input, Score, etc.).
• Repositories (*Repo.cs) – store component state and data.
• StateMachine (src/Component/Logic/StateMachine*) – drives state transitions.
d. Game Modules
• Creature Entities (e.g. BirdEntity) and their StateMachine (BirdStateMachine.g.puml).
• Environment Entities (e.g. PipeEntity, WorldBoundary).
• MovementStrategies (FollowPath, SideScrolling, TopDown).
• ScoreCounter & ScoreRegister – track and persist scoring.
e. Utils and Managers (src/Utils/*)
• SceneManager – handles scene loading transitions.
• SettingManager, FlagManager – global flags & settings.
• Converters, Generators – helper classes.
f. Persistence / External Services
g. Tests (test/src/GameTest.cs) – simple unit tests mocking ECS interactions.
Relationships and data flows
1. Godot Game Loop triggers scene loading via Main → GameContainer.
2. GameContainer reads level definitions (GameLevel.tscn, GameRepo) and spawns Entities into the EntityTable.
3. For each Entity:
– EntityTable invokes “scan & initialize” → components are retrieved via *Repo and attached.
– Components register to global events (input, update ticks).
4. Every frame:
– Input flows into ActionInputComponent → converts key presses to actions → updates entity states.
– MovementComponents fetch a MovementStrategy from MovementStrategyFactory, then compute new positions.
– AnimationComponents update sprite frames based on state.
– StateMachineComponents handle transitions (e.g. Flap, Fall, Collide).
– ScoreCounterComponent listens for collision events and updates the score repository.
– UI Components (in Gui.tscn) query repositories for current score and high scores.
5. Game over / Leaderboard:
– ScoreRegisterComponent persists the final score to local storage or calls an external API.
– SceneManager switches to leaderboard scene.
Architectural patterns and design principles
• ECS: decouples data (repositories) and behavior (components).
• MVVM‐like pattern: View (*.tscn + Godot nodes) is separate from Model (component state) and logic in C#.
• Repository pattern: isolates state persistence from behavior.
• DDD influence: clear boundaries between Entities, Value Objects (InputMapping), and Services (SceneManager).
• Strategy pattern: MovementStrategyHierarchy allowing interchangeable movement logic.
How to represent this
– Game Modules (green): BirdEntity, PipeEntity, GameLevel, MovementStrategy variants, Score components.
– Scenes & UI (purple): Main.tscn, GameContainer.tscn, Gui.tscn.
– Utils & Managers (yellow): SceneManager, SettingManager.
– External / Persistence (orange): Local file store or Leaderboard API.
– Rectangles for modules/packages.
– Rounded rectangles for classes/components.
d. Grouping
– Place all src/Component/* and src/Contract/* under the ECS Core group.
– Group scene files (*.tscn) at one edge, linking into the GameContainer.
e. Labels
Final checklist for the principal software engineer
• [ ] Include all six core ECS classes: EntityTable, Entity, Component, Repository, StateMachine, Factory.
• [ ] Show GameContainer’s role in scene orchestration.
• [ ] Map major game entities (Bird, Pipe, WorldBoundary) to their components.
• [ ] Group related classes by directory/package to reflect the file structure.
• [ ] Optionally annotate external persistence (leaderboard) even if not fully implemented.