How zxsrxt-kebab-case/snake-game works
This is a small C++ Snake game using Dear ImGui with a Win32/DirectX 11 presentation layer. The principal loop initializes the window and backend, reads arrow-key input, updates game state, renders the map and entities, then presents the frame. The game logic separates controller, snake, apple, and map responsibilities; rendering uses a small ImGui drawing helper. Edges follow the entry-point calls and documented/import references; the vendored ImGui internals are grouped as a framework rather than expanded into individual implementation files.
Main entry points: imgui.cpp ImGui Core · main.cpp Game Loop · GameRenderer.cpp Game Renderer · GameController.cpp Game Controller
Components 20
Application
- Game Loop
src/App/main.cpp - Win32 Window
src/App/Win/Win.cpp - DX11 Backend
src/App/ImGuiBackend/ImGuiBackend.cpp
Game State
- Game Controller
src/GameController/GameController.cpp - Snake
src/Entity/Snake/Snake.cpp - Apple
src/Entity/Apple/Apple.cpp - Map Bounds
src/Map/Map.cpp - Grid Vector
src/Math/Vector2.hpp
Rendering
- Game Renderer
src/GameRenderer/GameRenderer.cpp - Draw Elements
src/GameRenderer/RenderElements/RenderElements.cpp
Dear ImGui
- ImGui Core
external/imgui/imgui.cpp - Widgets
external/imgui/imgui_widgets.cpp - Tables
external/imgui/imgui_tables.cpp - Draw And Fonts
external/imgui/imgui_draw.cpp - Demo UI
external/imgui/imgui_demo.cpp - OpenGL3 Backend
external/imgui/backends/imgui_impl_opengl3.cpp - GLFW Backend
external/imgui/backends/imgui_impl_glfw.cpp - Vulkan Backend
external/imgui/backends/imgui_impl_vulkan.cpp - FreeType Fonts
external/imgui/misc/freetype/imgui_freetype.cpp
Other components
- Player
Connections 25
- Player → Game Loop: provides keys
src/App/main.cpp - Game Loop → Win32 Window: polls events
src/App/main.cpp - Game Loop → DX11 Backend: starts frames
src/App/main.cpp - Game Loop → Game Controller: sets input; updates
src/App/main.cpp - Game Loop → Game Renderer: renders state
src/App/main.cpp - Game Controller → Snake: updates
- Game Controller → Apple: manages
- Game Controller → Map Bounds: checks bounds
- Snake → Grid Vector: uses positions
- Apple → Grid Vector: uses position
- Map Bounds → Grid Vector: uses bounds
- Game Renderer → Draw Elements: draws elements
- Game Renderer → Snake: reads state
- Game Renderer → Apple: reads state
- Game Renderer → Map Bounds: reads bounds
- Draw Elements → ImGui Core: submits drawing
- DX11 Backend → Win32 Window: uses handle
- DX11 Backend → ImGui Core: initializes
src/App/ImGuiBackend/ImGuiBackend.cpp - ImGui Core → Widgets: uses
- ImGui Core → Tables: uses
- ImGui Core → Draw And Fonts: uses
- OpenGL3 Backend → ImGui Core: renders draw data
external/imgui/backends/imgui_impl_opengl3.cpp - GLFW Backend → ImGui Core: integrates platform
external/imgui/backends/imgui_impl_glfw.cpp - Vulkan Backend → ImGui Core: renders draw data
external/imgui/backends/imgui_impl_vulkan.cpp - FreeType Fonts → Draw And Fonts: builds fonts