How oosubhisara/rusty-snake works
rusty-snake is a Macroquad Snake game with single- and two-player modes. The runtime entry point creates and loads GameState, then repeatedly updates and draws it. GameState owns the gameplay flow: it handles input and level transitions, updates snakes and apples, and renders the playfield and status labels. Assets are loaded from the packaged data file through DataPakLoader. The excerpts show these principal calls; unsampled runtime details are represented only where the README or source index supports them.
Main entry points: gamestate.rs Game state · gamescene.rs Game scene · snake.rs Snake · apple.rs Apple
Components 12
Game runtime
- Game loop
src/main.rs - Game state
src/gamestate.rs - Shared timing
src/common.rs
Scene and UI
- Game scene
src/gamescene.rs - HUD labels
src/label.rs
Assets
- Asset manager
src/assets.rs - DataPak reader
src/datapakloader.rs - Packaged assets
data.pak
Other components
- Player
- Macroquad
Connections 19
- Player → Game state: chooses mode
README.md - Game loop → Game state: runs loop
src/main.rs - Game state → Snake: updates and draws
src/gamestate.rs - Game state → Apple: spawns and updates
src/gamestate.rs - Game state → Game scene: updates and draws
src/gamestate.rs - Game state → HUD labels: draws HUD
src/gamestate.rs - Game state → Asset manager: loads and uses
src/gamestate.rs - Game state → Shared timing: uses timers
src/gamestate.rs - Snake → Apple: checks collection
src/snake.rs - Snake → Game scene: draws on
src/snake.rs - Apple → Snake: avoids positions
src/apple.rs - Apple → Game scene: draws on
src/apple.rs - Game scene → Shared timing: animates with
src/gamescene.rs - Asset manager → DataPak reader: loads bundled data
src/assets.rs - DataPak reader → Packaged assets: reads
src/datapakloader.rs - Game loop → Macroquad: uses runtime
src/main.rs - Game scene → Macroquad: renders primitives
src/gamescene.rs - HUD labels → Macroquad: draws text
src/label.rs - Asset manager → Macroquad: loads audio and graphics
src/assets.rs