-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap1.cpp
More file actions
67 lines (57 loc) · 1.71 KB
/
Copy pathMap1.cpp
File metadata and controls
67 lines (57 loc) · 1.71 KB
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
#include "Wall.h"
#include "Finish.h"
#include "Maze.h"
#include "Space.h"
#include "Person.h"
#include "Hole.h"
#include "Banana.h"
#include <string>
//creates the map
Obstacle*** Map1(int MAPHEIGHT, int MAPWIDTH, Maze *maze, Person *person, Wall *wall, Finish *finish, Space *space, Hole *hole, Banana *banana) {
//Please don't judge my maze creation skills
std::string textMap[15] = { //creates an easily editable and readable map
"#########################",
"# # #",
"# ###(#### #### ######(#",
"#### # # # # # #",
"# O # ##### ### #",
"# # O ( #",
"# #(##### # ### # # ####",
"# # # # # # ( #",
"# ## # # ### #O# ### ##",
"# # # # # # ( O #",
"# ## # #######O# #",
"# # # # ### ( OXO #",
"# #O ### # # ## # #",
"# # # # # O###",
"#########################",
};
char currentChar= textMap[0].at(0);
// loop through textMap and allocate a dynamic array of obstacles in the correct positions
//remember to delete elsewhere
Obstacle*** myMap = new Obstacle**[MAPHEIGHT];
for (int i = 0; i < MAPHEIGHT; ++i) {
myMap[i] = new Obstacle*[MAPWIDTH];
for (int j = 0; j < MAPWIDTH; ++j) {
currentChar= textMap[i].at(j);
switch (currentChar) {
case '#':
myMap[i][j] = wall;
break;
case ' ':
myMap[i][j] = space;
break;
case 'O':
myMap[i][j] = hole;
break;
case '(':
myMap[i][j] = banana;
break;
case 'X':
myMap[i][j] = finish;
break;
}
}
}
return myMap;
}