How sabona-69/so_long works
Project type and purpose
• This is a native 2D maze game written in C, built with MiniLibX.
• It parses a map file (*.ber), loads textures, runs an event‐driven game loop, and renders frames to the screen.
• There are two build targets: so_long (mandatory) and so_long_bonus (bonus with animations, enemies, multiple levels).
File structure
• Top‐level:
• Makefile, README.md
• include/ – shared headers (so_long.h, so_long_b.h)
• mandatory/ & bonus/ – each contains subfolders:
– parse/ – map‐loading modules
– game/ – core gameplay logic
– utils/ – helper functions (I/O, string ops, GNL)
– handle_errors.* – error reporting
– root files (so_long.c, so_long_b.c)
• Asset folders:
• textures/ – XPM files grouped by theme (player, enemy, attack…)
• maps/ – .ber maze definitions
• Build artifacts: .o files in each directory.
README for additional insights
• Mandatory features: player movement, item collection, exit check
• Bonus features: animations, enemies, multi‐level, improved graphics
• Build commands: make → ./so_long map.ber, make bonus → ./so_long_bonus map.ber
1. Build System (Makefile)
2. Parser Module
3. Game State Manager
4. Input Handler
5. Renderer (MiniLibX + Texture Loader)
6. Animation & Enemy Controller (bonus)
7. Asset Manager (maps + textures)
8. Error Handler
9. Utility Library (get_next_line, string utils)
• Build System → compiles → all modules → Game binary (so_long, so_long_bonus)
• Game binary startup:
1. Parser Module loads map.ber via Asset Manager → builds initial Game State
2. Game Loop:
– Input Handler (keyboard events) → Game State Manager
– Game State Manager uses Animation & Enemy Controller (bonus)
– Renderer fetches Textures from Asset Manager → draws frame via MiniLibX
3. Game State Manager checks win/lose → calls Error Handler or cleanup
• Utility Library & Error Handler are used by all modules
c. Architectural patterns & principles:
• Modular separation: parsing, game logic, rendering, assets, error handling
• Event‐driven loop pattern (input → update → render)
• Single codebase with feature flags (mandatory vs bonus)
d. Key technologies & libraries:
• C99 (Makefile)
• MiniLibX for window management & rendering
• XPM textures
• Custom GNL for file I/O