-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps.cpp
146 lines (138 loc) · 3.33 KB
/
maps.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <iostream>
#include <sstream>
#include "mapgen.cpp"
#include "stringsplit.cpp"
using namespace std;
int width = 80;
int height = 30;
int walls = 40;
int smooth = 9;
int seed = time(NULL);
int density = 5;
int isolation = 2;
string prompt;
void reBuild(int menu);
int main(int argc, char* argv[])
{
//first map
reBuild(1);
bool menuGetDimensions = false;
bool menuGetThree = false;
bool menuGetWalls = false;
bool menuGetSeed = false;
while(true)
{
// note...this does no checking of input
// enter exactly what it wants!
cout << prompt;
string cmd;
getline(cin,cmd);
// go into a submenu and stay there if that menu was choosen
if (menuGetDimensions){
vector<string> x = split(cmd, ',');
width = atoi(x[0].c_str());
height = atoi(x[1].c_str());
menuGetDimensions = false;
reBuild(1);
}
else if (menuGetThree){
vector<string> x = split(cmd, ',');
smooth = atoi(x[0].c_str());
density = atoi(x[1].c_str());
isolation = atoi(x[2].c_str());
menuGetThree = false;
reBuild(1);
}
else if (menuGetWalls){
walls = atoi(cmd.c_str());
menuGetWalls = false;
reBuild(1);
}
else if (menuGetSeed){
seed = atoi(cmd.c_str());
menuGetSeed = false;
reBuild(1);
}
// main menu commands...
else if (cmd == "n") {
smooth = 1;
density = 1;
isolation = 1;
reBuild(1);
}
else if (cmd == "r") {
smooth = 1;
density = 1;
isolation = 1;
seed = time(NULL);
reBuild(1);
}
else if (cmd == "w") {
menuGetDimensions = true;
reBuild(2);
}
else if (cmd == "t") {
menuGetThree = true;
reBuild(3);
}
else if (cmd == "e") {
menuGetWalls = true;
reBuild(4);
}
else if (cmd == "s") {
menuGetSeed = true;
reBuild(5);
}
else if (cmd == "z") {
smooth++;
reBuild(1);
}
else if (cmd == "x") {
density++;
reBuild(1);
}
else if (cmd == "c") {
isolation++;
reBuild(1);
}
else if (cmd == "q")
break;
else {
reBuild(1);
}
}
return 0;
}
void reBuild(int menu)
{
switch (menu) {
case 1:
prompt = "Enter menu command: ";
break;
case 2:
prompt = "Enter as width,height...ex 80,30: ";
break;
case 3:
prompt = "Enter Smoothing, Density, Isolation as x,y,z: ";
break;
case 4:
prompt = "Enter a number for % of walls: ";
break;
case 5:
prompt = "Enter a number for random seed: ";
break;
default:
break;
}
vector<int> iterations;
// note, we can actually have multiple sets of density, isolation, smooth
// but I find with good values entered to begin with its not needed
iterations.push_back(density);
iterations.push_back(isolation);
iterations.push_back(smooth);
MapGen map = MapGen(seed, width, height, walls, iterations);
cout << "(q)Quit " << "(r)Reset " << "(s)Seed " << "(w)Width,Height " <<
"(e)Wall% " << endl;
cout << "(t)Set All Three " << "(n)New" << endl;
cout << "(z)Smooth +1 " << "(x)Density +1 " << "(c)Isolation +1" << endl;
}