How pythops/snakers works
Snakers is a terminal Snake game. The main loop initializes game state and the terminal UI, draws the current state, then processes timed ticks and keyboard input until the player quits; ticks advance the snake and collisions or wall contact end the game. The renderer displays the snake, prey, score, and game-over prompt, while the key handler supports direction changes and restarting. The README documents arrow keys and vi-style movement. The graph follows the sampled runtime source; no separate persistence or service layer is present.
Main entry points: main.rs Game loop · app.rs Game state and rules · event.rs Event polling · tui.rs Terminal UI
Components 9
Game state
- Game state and rules
src/app.rs
Terminal interaction
- Game loop
src/main.rs - Key handler
src/handler.rs - Event polling
src/event.rs
Game display
- Terminal UI
src/tui.rs - Game renderer
src/ui.rs
Other components
- Player
- Terminal
- Random generator
Connections 15
- Game loop → Game state and rules: creates state
- Game loop → Event polling: starts polling
- Game loop → Terminal UI: initializes and draws
- Game loop → Event polling: receives events
- Event polling → Game loop: sends events
- Player → Terminal: presses keys
- Event polling → Terminal: polls input
- Game loop → Game state and rules: ticks game
- Game loop → Key handler: dispatches keys
- Key handler → Game state and rules: updates controls
- Terminal UI → Game renderer: renders state
- Game renderer → Game state and rules: reads and sets bounds
- Game state and rules → Random generator: generates prey
- Terminal UI → Terminal: configures display
- Game renderer → Terminal: draws game