# CppGameHub **Repository Path**: mengHang_Chen173/cpp-game-hub ## Basic Information - **Project Name**: CppGameHub - **Description**: 大学生cpp游戏项目实战 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-08 - **Last Updated**: 2025-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## david 陈萌航 2023905931 ## Viclant 吴彦澜 2023905330 ## rock 赵昱博 2023905420 # DUNGEON ESCAPE ## Game Overview DUNGEON ESCAPE is a console-based dungeon escape RPG game developed in C++. Players take on the role of a hero who must explore, battle, and find a way out of a maze composed of multiple rooms. Different rooms contain enemies with varying attributes. Defeating different enemies randomly drops items with random attributes. The game ends when the player defeats the boss enemy or when the player's health reaches zero. ## Core Gameplay 1. **Map Exploration**: Move between connected rooms (North/South/East/West) 2. **Item Collection**: Pick up equipment that enhances attributes and recovery items 3. **Turn-based Combat**: Battle enemies and automatically receive counterattacks 4. **Status Management**: View character attributes and inventory 5. **Game Over**: The game ends when the player's health reaches zero or kill the lin of the enemy. ## Technical Summary 1. **Object-Oriented Design**: - Clear class inheritance hierarchy (Player/Enemy → Character) - Polymorphism application (attack/takeDamage methods) 2. **Memory Management**: - Comprehensive destructor mechanism ensures no memory leaks - Smart pointers for resource management 3. **Game Systems**: - Room class constructs game world and room connections - Random loot generation system - Turn-based auto-combat mechanism 4. **Code Quality**: - Follows RAII principle - Comprehensive copy control - Modular design for easy feature expansion ``` # MAPS: [ THRONE ROOM ] ▲ │ [ LIBRARY ] ◄─ [ CORRIDOR ] ─► [ ARMORY ] │ | [ STARTING CHAMBER ] # Memory management ``` ``` [Item::generateRandomLoot()] (item.cpp) | v new Item | v Enemy::dropLoot() (Enemy.cpp) | v std::vector loot (Player.cpp) | v Room::addItem(item) (Player.cpp) | v Room::items have Item* (drops -> loot -> items) | v Room::~Room() (room.cpp) | v delete Item* (both in items and drops ) ``` ``` Character::~Character() { for (Item* item : inventory) delete item; } (delete Item* in inventory) ``` ``` Room::~Room() { for (Item* item : items) { delete item; } for (Enemy* enemy : enemies) { delete enemy; } } (delete Enemy* in enemies ,Item* in items) ``` ``` Map::~Map() { for (Room* room : rooms) { delete room; } rooms.clear(); } (delete Room*) ``` ``` new Item() → 1. Room::items ←【初始位置】 ↓ Player::takeItem() ↓ 2. Character::inventory ←【转移所有权】 ↓ 3. Character::~Character() → delete item 或: 1. Room::items ←【未捡起】 ↓ 4. Room::~Room() → delete item 或(敌人掉落): Enemy::dropLoot() → Room::addItem() → 如 1 或 2 处理 ```