How parrotpotato/bread works
Project type and purpose
• This is a native C++ 2D game engine and demo game (“Bread”) built from scratch.
• It uses SDL2 for windowing/input, OpenGL (with GLEW) for rendering, and ImGui for in-engine debugging/tools (tile editor).
• Core features: tile‐map editor, simple physics (SAT collisions), hot code reloading.
File structure
• Top-level: CMakeLists.txt, compile_commands.json, README.md for build/config.
• external/imgui: third-party Immediate UI library used in debugging/tooling.
• images: asset folder for screenshots and in-editor sprites.
• src/: all engine & game code, subdivided by feature/file naming:
• main.cc: application entry point & game loop
• gamespace.{cc,hh}: high-level game state manager
• events.hh: input/events abstraction
• platform.{cc,hh}: OS abstractions (SDL2 wrappers)
• physics.{cc,hh}: 2D collision detection & response
• memory.{cc,hh}: custom allocators/memory pools
• util.{cc,hh}: shared utilities/helpers
README
• Confirms technology stack: SDL2, OpenGL, GLEW, ImGui.
• Highlights functional modules: tile editor, physics engine, hot code reload.
Main components and their relationships
a. Components
1) Platform Layer: SDL2 window/input, time, file I/O wrappers (src/platform)
2) Renderer: OpenGL context, shader management, sprite batcher (in util or gamespace)
3) Asset/Tile Manager: loads spritesheets, textures (part of gamespace or util)
4) Event System: abstracts SDL2 events into engine events (src/events)
5) Game Space Manager: world/state, tile editor, entity management (src/gamespace)
6) Physics Engine: collision detection & response (src/physics)
7) Memory Manager: custom allocators for fast alloc/free (src/memory)
8) UI/Debug Tools: ImGui integration (external/imgui + src/platform/util)
9) Application Layer: main loop, subsystem initialization & orchestration (src/main.cc)
b. Interactions
• main.cc initializes Platform → Renderer → Asset Manager → Physics → Event System → Game Space → UI
• Every frame:
1) Platform polls SDL events → Event System
2) Event System dispatches to Game Space & UI
3) Game Space updates physics, world state
4) Renderer draws world & UI
5) Memory Manager services all dynamic allocations
• Hot code reload hooks into Platform and Game Space to swap DLL/so modules at runtime.
c. Architectural patterns & principles
• Layered architecture: clear separation between platform/OS, core engine, game logic, and tools.
• Single game loop orchestrator (main.cc) controlling subsystems.
• Dependency inversion for better testability: subsystems depend on abstract interfaces (events.hh, platform.hh).
• Asset hot-reloading plugged into platform file-watcher.
d. Key technologies
• SDL2: window, input, timing
• OpenGL + GLEW: GPU rendering
• ImGui: Immediate-mode UI for tile editor & debugging
• CMake: build system