How 36vanquyet/snake_game works
This is a console-menu and SDL Snake game. The main workflow is menu selection, game setup and play, then player-name entry and score saving; players can also browse scores and game guidance from the menu. The game includes difficulty levels, boundary walls, and hard-mode moving/random obstacles, while rendering and keyboard input are handled separately. The graph follows the sampled entry points and documented features; some internal runtime calls are not shown in the excerpts, so uncertain links are omitted.
Main entry points: game.cpp Game Orchestrator · main.cpp Application Entry · menu_choices.cpp Menu Selection · controller.cpp Keyboard Controller
Components 13
Entry and Menu
- Application Entry
src/main.cpp - Menu Selection
src/menu_choices.cpp - Score Browsing
src/menu_choices.cpp - Game Guide
src/menu_choices.cpp - Terminal Utilities
src/system_common.cpp
Game Runtime
- Game Orchestrator
src/game.cpp - Snake Simulation
src/snake.cpp - Level Obstacles
src/game.cpp
Input and Display
- Keyboard Controller
src/controller.cpp - SDL Renderer
src/renderer.cpp
Score Records
- JSON Score Store
src/manager_db.cpp - Level Name Parser
src/parser_string.cpp
Other components
- Player
Connections 19
- Player → Application Entry: starts
src/main.cpp - Application Entry → Menu Selection: runs menu
src/main.cpp - Menu Selection → JSON Score Store: reads scores
- Player → Menu Selection: chooses options
README.md - Menu Selection → Score Browsing: opens scores
README.md - Menu Selection → Game Guide: opens guide
README.md - Menu Selection → Terminal Utilities: uses utilities
src/menu_choices.cpp - Application Entry → Game Orchestrator: starts play
src/main.cpp - Application Entry → Keyboard Controller: creates
src/main.cpp - Application Entry → SDL Renderer: creates
src/main.cpp - Player → Keyboard Controller: steers snake
src/controller.cpp - Game Orchestrator → Level Obstacles: manages
README.md - Game Orchestrator → JSON Score Store: saves score
src/game.cpp - Game Orchestrator → Level Name Parser: uses parser
src/game.cpp - Player → Application Entry: provides name
src/main.cpp - Application Entry → JSON Score Store: persists result
src/main.cpp - Game Orchestrator → Snake Simulation: updates state
- Game Orchestrator → SDL Renderer: renders frame
- Game Orchestrator → Keyboard Controller: handles input