How nu7h/comp2113_minigame_project works
1. This is a single-player C++ terminal game built as one executable (make && ./build/game). The architecture is centered on an update/render loop driven by main.cpp, with all gameplay presented as ASCII art and text rather than graphics APIs.
2. Game is the top-level orchestrator. It likely owns the current mode/state, runs the main loop, coordinates input, updates entities, handles room transitions, and decides when to show cutscenes, gameplay, pause, or outro screens. GameState.h and Difficulty.h provide the shared state/config enums used across the codebase.
3. Render is the presentation boundary. It turns the current game state into console output: room geometry, player/enemy symbols, hearts, attack particles, projectiles, lock indicators, and the HUD. The README’s symbol table maps directly to this rendering layer.
4. Map is the world/layout subsystem. It reads room files from the room/ directory and likely exposes collision data, exits, and room-specific logic such as blocked doors until enemies are defeated. Room transitions are data-driven through these text maps rather than hardcoded level geometry.
5. Entity is the shared gameplay abstraction. Player and Enemy derive from it, which suggests common fields like position, health, direction, and update/collision behavior. This is the main object model for in-game actors.
6. Player handles movement, facing direction, attacks, shield activation, invincibility frames, and health changes. Its state is reflected both in gameplay logic and in the HUD. The README indicates the player can attack, block projectiles, and take temporary damage immunity after hits.
7. Enemy encapsulates slime/boss behavior. Enemies can wander, chase the player, and fire projectiles when in range. Their per-room count and speed depend on the selected difficulty, so Enemy is tied to both AI behavior and difficulty scaling.
8. Cutscene is a separate content-and-flow subsystem used for intro/outro sequences. It reads scripted text/ASCII art from Intro/ and Outro/ assets, which keeps narrative presentation outside the core room-combat loop. This makes the game’s opening and ending flow distinct from normal gameplay.
9. Input is the control boundary between keyboard events and game actions. The README shows direct mappings for movement, attack, shield, pause, quit, and save/continue decisions. Game likely consumes input and dispatches it to player movement or global state changes.
10. The main data flow is: keyboard input -> Game state update -> Player/Enemy/Map logic -> collision/combat/resolution -> Render output. The game loop is therefore state-driven and frame-based, with map data and entity state feeding the renderer every cycle.
11. Persistence is local and lightweight. The README describes save/load on quit and restart, storing room, player position, difficulty, and enemy states. That makes save handling another cross-cutting concern owned by Game, not a separate service.
12. Content is heavily externalized into text assets. room/*.txt defines playable areas, while Intro/ and Outro/ contain scripted scenes and ASCII art. That separation means the engine is relatively small, and most variation comes from data files rather than code.
13. Overall boundaries are clean: main boots the app, Game manages progression, Map defines space, Entity/Player/Enemy define actors, Render draws, Input reads controls, and Cutscene handles narrative screens. This is a classic console game architecture with data-driven rooms and a simple state machine at the center.
Main entry points: Game.h Game · Render.h Render · Enemy.h Enemy · Map.h Map
Components 16
Core loop
Runtime orchestration and shared game state.
- main · Boots the executable and starts the game loop.
main.cpp - Game · Owns mode flow, update loop, transitions, and save/load.
Game.h - State · Shared game-mode states used across the loop.
GameState.h - Difficulty · Global difficulty settings for scaling gameplay.
Difficulty.h - Input · Maps keyboard events to actions and global commands.
Input.h - Makefile · Builds the single executable.
Makefile
World & actors
Map data and in-game entities.
- Map · Loads room layouts and collision/transition data from text maps.
Map.h - Entity · Shared actor interface for position, health, and updates.
Entity.h - Player · Handles movement, facing, attacks, shield, and invincibility.
Player.h - Enemy · Implements slime and boss behavior, chasing, and projectiles.
Enemy.h
Presentation
Console rendering and scripted scenes.
Content
Text assets that drive rooms and cutscenes.
- Intro assets · ASCII art and scripted intro frames.
Intro - Outro assets · ASCII art and scripted ending frames.
Outro - Room files · Data-driven room layouts and blocked-door layouts.
room - README · Documents controls, symbols, save flow, and content mapping.
README.md
Connections 24
- main → Game: starts · main creates and runs the game loop.
- Game → State: uses · Game drives mode changes through shared state.
- Game → Difficulty: uses · Difficulty affects scaling and progression.
- Game → Input: consumes · Game reads controls and global commands.
- Game → Map: loads · Game selects and updates the active room.
- Game → Player: updates · Game applies input and progression to the player.
- Game → Enemy: updates · Game advances enemy AI and combat.
- Game → Render: draws · Game sends current state to the renderer.
- Game → Cutscene: switches to · Game enters intro/outro flows when needed.
- Map → Room files: reads · Room layouts come from text files.
- Player → Entity: inherits · Player extends the shared actor base.
- Enemy → Entity: inherits · Enemy extends the shared actor base.
- Player → Map: collides with · Player movement is constrained by room geometry.
- Enemy → Map: spawns in · Enemies live inside loaded rooms.
- Enemy → Difficulty: scales with · Enemy count and speed vary by difficulty.
- Render → Map: visualizes · Renderer draws room geometry and exits.
- Render → Player: visualizes · Renderer shows player position and status.
- Render → Enemy: visualizes · Renderer shows enemies and combat effects.
- Render → State: reflects · HUD and screen content depend on current mode.
- Cutscene → Intro assets: reads · Intro sequences are sourced from scene text files.
- Cutscene → Outro assets: reads · Outro sequences are sourced from ending text files.
- README → Input: documents · Controls and key mappings are described here.
- README → Render: documents · Symbol table explains rendered ASCII elements.
- Makefile → main: builds · Makefile compiles the executable entrypoint.