How juannbel/duck-game works
Project type and purpose
• This is a C++‐based 2D multiplayer shooter game (“Duck Game”) with three main executables:
• duck_game_server – runs the authoritative game logic and networking
• duck_game_client – the game client with rendering, input, audio
• duck_game_editor – a Qt5‐based level editor for creating YAML map files
• It also provides a shared “common” library of utilities (sockets, threading, config, DTOs).
File structure
• Top‐level directories:
• client/ – source for the client, broken into networking (client_protocol, sender/receiver), rendering (renderables, animation, textures_provider), input (controls_config, joystick_manager), UI screens (lobby, pre_lobby), audio (sound_manager), main loop (constant_looper)
• server/ – source for the server, includes acceptor/receiver/sender modules, game loop and game logic (game, game_loop, game_operator, managers for bullets/collectables), entity definitions (duck_player, bullet_entity, gun_entity), map loader, YAML maps under server/maps/
• common/ – shared headers and implementations: socket, resolver, threading, config, blocking_queue, commands, DTOs (map_dto, snapshot), shared constants
• editor/ – Qt5 UI (mainwindow.ui) and logic to open, edit, save YAML maps
• tests/ – unit tests for client_protocol and server_protocol
• Build system uses CMake and Makefiles, dependencies: SDL2 (image, mixer, ttf), Qt5, YAML‐cpp.
README for additional insights
• Confirms client-server architecture, network protocol (custom commands.h) over sockets
• Game loop on server enforces rules and broadcasts snapshots
• Clients render snapshots, send input commands
• Editor reads/writes same map YAML files that server loads
a. Main components
• Server Process
– Network Stack (Acceptor, Receiver, Sender)
– Game Loop & Logic (game_loop, game_operator, managers, entities)
– Map Loader (reads YAML maps)
• Client Process(es)
– Network Stack (client_receiver, client_sender, client_protocol)
– Input Layer (camera, joystick_manager, controls_config)
– UI Layer (pre_lobby, lobby screens)
– Rendering Engine (SDL2: textures_provider, renderables, animation_data_provider)
– Audio Engine (sound_manager, mixer)
– Main Loop (constant_looper)
• Editor Process
– Qt5 UI (mainwindow)
– Map Serialization (YAML‐cpp)
• Shared Library (common/)
• External Dependencies (SDL2, Qt5, YAML‐cpp)
b. Relationships and interactions
• Clients ↔ Server: TCP/UDP sockets, protocol defined in common/commands.h and client_protocol/server_protocol
• Server loads maps from disk, updates game state, pushes snapshots to all connected clients
• Clients send input commands (move, shoot) to server
• Editor reads/writes the same YAML map files that server consumes
• common/ library code linked by both client and server
c. Architectural patterns & principles
• Layered Architecture: Network layer, game logic layer (server), application layer (client, editor)
• Model‐View‐Controller (MVC)-like separation in client: input (controller), game state (model from server), rendering & UI (view)
• Publisher/Subscriber style: server publishes state snapshots, clients subscribe to updates
• Plugin-style asset providers: textures_provider, animation_data_provider load data from filesystem at runtime
d. Key technologies & frameworks
• SDL2 (rendering, image, audio, TTF)
• Qt5 (editor UI)
• YAML-cpp (map serialization)
• CMake/Make for cross‐platform build
• STL threading + custom blocking_queue
Detail
• Protocols by referencing the common/commands.h definitions
• Data flows—map loading, snapshot broadcast, input sending—are represented