How lisagheclys/sokoban_2021-epitech works
Main Components
• Entry Point & Command Processing: Represented by src/main.c, which parses the command-line arguments (e.g., a map file or the -h flag) and sets the stage for the game.
• Initialization & Map Loading: The initialization module (src/init.c) and map validation (src/is_the_right_map.c) work together to load and verify the map file coming from the maps/ directory. This component is responsible for setting up the initial game state.
• Core Game Logic: The heart of the application is in src/my_sokoban.c along with other logic files (src/movement.c, src/lose.c, src/win.c, src/reload.c) that implement player movement, check for win/lose conditions, and refresh the game state.
• Utility and Display Functions: Utility libraries in lib (especially under lib/my such as my_printf.c and its related functions) provide functions for console output, string handling, and number formatting. These support the game’s display and debugging.
• Header Declarations: The include/ directory (with files like myprintf.h and mysokoban.h) defines the interfaces for the functions used throughout the project.
• Build & Documentation: The Makefile and the usage help text (usages/help.txt) define the build process and assist users in understanding how to run the game.
Relationships and Interactions
• The Main Component (src/main.c) invokes the Initialization Module, which in turn calls the Map Loader/Validator to read and verify the map file.
• Once initialized, control passes to the Game Loop implemented via the core game logic files. This module handles player input (e.g., moves) that update the game state.
• After each state change, display functions from the Utility Library (lib/my) are used to refresh the visual output on the console.
• The header files in include/ ensure consistent function declarations across modules, maintaining clear interfaces.
• Build scripts (Makefile) integrate these pieces during compilation, while the README and help text provide operational guidance.
Architectural Patterns & Design Principles
• Separation of Concerns: There’s a clear division between initialization/map loading, core game logic (movement, win/lose checks), and utility functions for display/output.
• Modular Design: Each directory (src, lib, include) contains logically grouped code. The design favors maintainability with specialized modules handling specific tasks (e.g., map validation vs. movement).
• Layered Interaction: The game consists of layers—from input/initialization to game processing and finally to output and feedback—with well-defined interaction points (via function calls and header interfaces).
Technologies & Frameworks
• Language: C (using standard libraries and custom implementations for printing and string manipulations).
• Build Tools: Makefile for building the project.
• Resources: Simple text-based maps that serve as game levels.
• Console I/O: Custom my_printf and related functions provide enhanced output handling on the terminal.
Final Assembly
• Key components and their relationships are present.
Happy diagramming!