How dlurak/voxelbox-3d-pong works
Main System Components
• Main Entry Point (src/main.rs): This is where initialization occurs and the game loop is started.
• CLI Module (src/cli.rs): Manages command-line interactions and configuration options.
• Game Controller & Game Loop:
– This is orchestrated largely through src/controller.rs, which directs the game flow.
– The core game logic is in the “game” directory with modules like ball.rs, ball_movement.rs, collision.rs, input.rs, player.rs, and state.rs.
• Input Handler:
– Located in the src/input directory (joystick.rs, mod.rs); it abstracts gamepad inputs (like from a Dualshock 4).
• Hardware / LED Cube Interface:
– In modules such as src/voxelbox.rs, this component manages the communication with the physical LED cube (or its simulator) so that the game state gets reflected visually.
• Auxiliary and Utility Modules:
Relationships and Data Flow
• The application begins in main.rs, which initializes the CLI for setup and then instantiates the game controller.
• The Game Controller triggers the game loop; within this loop, game state is updated based on events.
• The Input Handler continuously listens for joystick (or other gamepad) inputs and forwards these events into the game logic.
• Game State & Game Entities (ball, player, collision mechanics) are updated per input and internal game rules.
• Updated game state is then sent to the LED Cube Interface, which converts game data into the visual output on the LED cube or simulator.
• Optionally, logging and error handling (from log.rs and other utility modules) tie into each layer for monitoring and debugging.
Architectural Patterns and Design Principles
• Modular Design: Each logical part (CLI, input, game logic, hardware interface) is kept in a dedicated module or directory.
• Separation of Concerns: Input, game state management, and hardware output are cleanly separated.
• Event-Driven Game Loop: Input events are processed in a loop that updates the game state dynamically.
Relevant Technologies and Tools
• Rust as the programming language with Cargo managing dependencies.
• Nix (flake.nix, flake.lock) indicating that development environments are reproducible.
• The use of a simulator for local development, which implies an abstraction layer that decouples game logic from hardware.