How moise7000/pakbolombrik-c-game works
Project Type and Purpose
• This is a native C-based 2D game (“Bâtô & Ver2Ter”) using SDL2 for graphics/audio/input and Jansson for JSON parsing.
• The goal is to run a game loop that loads scene definitions (JSON), instantiates entities/weapons, updates physics/collisions, renders frames, plays audio, and handles user input.
File Structure Analysis
• Top-level: build scripts (Makefile, Dockerfile, CI config), asset export scripts (assets_to_code.sh), raw Aseprite art directory.
• bin/: compiled executable (“game”) + JSON scene outputs and dialogs.
• src/: all C sources, subdivided into:
• engine/ (core subsystems: assets, collisions, physics, framerate, game loop, HUD, dialogs, scenes)
• scenes/ (one folder per level, each with .c/.h logic + .json data)
• entities/ (per-entity logic modules)
• weapons/ (per-weapon logic modules)
• assets/ (fonts, structured assets for build)
• main.c (initializes SDL2, Jansson, enters game loop)
README Insights
• Dependencies: SDL2 family, libjansson.
• Describes the expected directory layout, the role of each folder.
a. Main Components
• Core Engine / Game Loop
• Input Manager (SDL2 events)
• Asset Loader (images, fonts, audio, JSON)
• Scene Manager (loads JSON, orchestrates level logic)
• Entity Manager (creates/destroys entities)
• Weapon Manager (similar to entities)
• Physics & Collision Subsystem
• Renderer / Graphics Subsystem (SDL2 + textures)
• Audio Subsystem (SDL2_mixer)
• HUD Subsystem (texts, health bars)
• Data Layer (scene JSON, dialogs JSON)
• External Libraries (SDL2, SDL2_image, SDL2_ttf, SDL2_mixer, Jansson)
• Tools & Assets (Aseprite files → asset pipeline scripts)
b. Relationships & Data Flow
1. main.c initializes subsystems (Asset Loader, SDL2, JSON parser)
2. Game Loop tick:
• Input Manager → updates global input state
• Entity/Weapon Managers → update all instances’ logic
• Physics/Collision → compute movements, detect collisions
• Audio → play SFX/music based on events
3. Asset Loader serves textures, audio, JSON to all subsystems on demand.
c. Architectural Patterns
• Modular C design with clear separation of concerns
• Data-driven levels & dialogs via JSON → decouples content from code
• Engine-as-service: each subsystem exposes C API via include/*.h
• Per-module folders facilitate compile-time modularity
d. Key Technologies & Libraries
• SDL2 suite for cross-platform media
• Jansson for JSON parsing
• Custom data structures (hashtable, linked list, binary heap) in engine/structures
• Aseprite → asset pipeline scripts convert to in-code or engine-readable formats