-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.cpp
95 lines (76 loc) · 3.68 KB
/
map.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*******************************************************************************
* Filename: map.cpp *
* Author: Daniel Wilson *
* E-Mail: [email protected] *
* Date: 10 June 2017 *
* *
* Description: Provides function definitions that are used in the creation of *
* the game map. *
* *
*******************************************************************************/
#include "Location.hpp"
/*******************************************************************************
* Function: createMap *
* *
* Description: Creates all of the locations for the Escape the Cabin game and *
* returns a pointer to the starting location. *
* *
* Inputs: void *
* *
* Outputs: Location* - the starting location (cabin) *
*******************************************************************************/
Location* createMap()
{
Location* cabin = new Cabin();
Location* car = new Car();
Location* garden = new Garden();
Location* junkpile = new Junkpile();
Location* forest = new Forest();
Location* cliffwall = new Cliffwall();
Location* shed = new Shed();
Location* lakeshore = new Lakeshore();
Location* boat = new Boat();
cabin->setSouth(car);
cabin->setWest(garden);
cabin->setEast(junkpile);
cabin->setNorth(forest);
car->setNorth(cabin);
garden->setEast(cabin);
junkpile->setWest(cabin);
forest->setSouth(cabin);
forest->setWest(cliffwall);
forest->setEast(lakeshore);
forest->setNorth(shed);
cliffwall->setEast(forest);
shed->setSouth(forest);
lakeshore->setWest(forest);
lakeshore->setSouth(boat);
boat->setNorth(lakeshore);
return cabin;
}
/*******************************************************************************
* Function: destroyMap *
* *
* Description: Deletes the entire map, but must be passed the cabin location *
* to properly work. *
* *
* Inputs: destroyMe - Location* (must be cabin) *
* *
* Outputs: void *
*******************************************************************************/
void destroyMap(Location* destroyMe)
{
Location* tempLocation = destroyMe->getNorth();
delete destroyMe->getWest();
delete destroyMe->getSouth();
delete destroyMe->getEast();
delete destroyMe;
destroyMe = tempLocation;
delete destroyMe->getWest();
delete destroyMe->getNorth();
tempLocation = destroyMe->getEast();
delete destroyMe;
destroyMe = tempLocation;
delete destroyMe->getSouth();
delete destroyMe;
}