|
TheCOSCGameProject
1.0
|
Manages the generation and traversal of dungeon floors. More...
#include <dungeon.h>
Public Member Functions | |
| Dungeon () | |
| Constructor for the Dungeon class. More... | |
| ~Dungeon () | |
| Destructor for the Dungeon class. More... | |
| Room * | generateFloor (int numRooms) |
| Generates a dungeon floor with a specified number of rooms. More... | |
| int | numRooms (Room *startRoom) |
| Counts the number of rooms in the dungeon starting from a given room. More... | |
| void | linkRooms (Room *room1, Room *room2, int direction) |
| Links two rooms together in a specified direction. More... | |
| std::string | getMap (Room *room) |
| Get a string representation of the dungeon map centered on a specific room. More... | |
Manages the generation and traversal of dungeon floors.
The Dungeon class handles the creation of a dungeon floor with a specified number of rooms, linking rooms together, and providing methods to traverse and print the contents of the dungeon.
| Dungeon::Dungeon | ( | ) |
| Dungeon::~Dungeon | ( | ) |
| Room * Dungeon::generateFloor | ( | int | numRooms | ) |
Generates a dungeon floor with a specified number of rooms.
Public method to generate a floor with a specified number of rooms.
| numRooms | The number of rooms to generate in the floor. |
| numRooms | The number of rooms to generate. |
This method generates a floor by creating a starting room and linking additional rooms to it until the specified number of rooms is reached.
| std::string Dungeon::getMap | ( | Room * | room | ) |
Get a string representation of the dungeon map centered on a specific room.
| room | The room to center the map on. |
The map displays a 5x5 grid centered on the given room, with visited rooms marked with '*', unvisited rooms with 'X', and the current room in blue.
Links two rooms together in a specified direction.
Private method to link two rooms together in a specified direction.
| room1 | A pointer to the first room. |
| room2 | A pointer to the second room. |
| direction | The direction in which to link the rooms (0 = north, 1 = south, 2 = west, 3 = east). |
| room1 | The first room to link. |
| room2 | The second room to link. |
| direction | The direction from room1 to room2 (0: North, 1: South, 2: West, 3: East). |
| int Dungeon::numRooms | ( | Room * | startRoom | ) |
Counts the number of rooms in the dungeon starting from a given room.
Public method to count the number of rooms in the dungeon.
| startRoom | A pointer to the room from which to start counting. |
| startRoom | A pointer to the room where the count begins. |
Counts the total number of rooms in the dungeon starting from the given room and traversing all connected rooms.
1.8.13