-
Notifications
You must be signed in to change notification settings - Fork 6
/
classes.hpp
274 lines (196 loc) · 5.04 KB
/
classes.hpp
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
//
// classes.hpp
// Undiscovered Worlds
//
// Created by Jonathan Hill on 17/04/2020.
//
// Please see functions.hpp for notes.
#ifndef classes_hpp
#define classes_hpp
#include <iostream>
#include <cmath>
#include <fstream>
#include <stdio.h>
#include <queue>
#define PEAKWIDTH 20
#define PEAKHEIGHT 20
#define PEAKTOTAL 5
using namespace std;
// These are some very simple classes for holding multiple values.
class twointegers
{
public:
twointegers(); // constructor
~twointegers(); // destructor
int x;
int y;
};
class threeintegers
{
public:
threeintegers(); // constructor
~threeintegers(); // destructor
int x;
int y;
int z;
};
class fourintegers
{
public:
fourintegers(); // constructor
~fourintegers(); // destructor
int w;
int x;
int y;
int z;
};
class fourshorts
{
public:
fourshorts(); // constructor
~fourshorts(); // destructor
short w;
short x;
short y;
short z;
};
class fiveintegers
{
public:
fiveintegers(); // constructor
~fiveintegers(); // destructor
int v;
int w;
int x;
int y;
int z;
};
class twofloats
{
public:
twofloats(); // constructor
~twofloats(); // destructor
float x;
float y;
};
class threefloats
{
public:
threefloats(); // constructor
~threefloats(); // destructor
float x;
float y;
float z;
};
class twolongdoubles
{
public:
twolongdoubles(); // constructor
~twolongdoubles(); // destructor
long double x;
long double y;
};
class threelongdoubles
{
public:
threelongdoubles(); // constructor
~threelongdoubles(); // destructor
long double x;
long double y;
long double z;
};
class globepoint
{
public:
globepoint(); // constructor
~globepoint(); // destructor
short face;
short x;
short y;
};
class fourglobepoints
{
public:
fourglobepoints(); // constructor
~fourglobepoints(); // destructor
globepoint north;
globepoint east;
globepoint south;
globepoint west;
};
class fourdirs
{
public:
fourdirs(); // constructor
~fourdirs(); // destructor
unsigned char north;
unsigned char east;
unsigned char south;
unsigned char west;
};
// This class holds the templates for the mountain peaks. All the templates are held in a single object and accessed by index.
class peaktemplate
{
public:
peaktemplate(); // constructor
~peaktemplate(); // destructor
// Accessor functions
int span(int index) const; // Width/height
void setspan(int index, int amount);
int centrex(int index) const; // Centre x coordinate
void setcentrex(int index, int amount);
int centrey(int index) const; // Centre y coordinate
void setcentrey(int index, int amount);
int peakmap(int index, int x, int y) const; // Peak height map
void setpeakmap(int index, int x, int y, int amount);
private:
int itsspan[PEAKTOTAL]; // Width/height of the peak
int itscentrex[PEAKTOTAL];
int itscentrey[PEAKTOTAL]; // Coordinates of the centre of the peak
int itspeakmap[PEAKTOTAL][PEAKWIDTH][PEAKHEIGHT]; // Map of the peak heights
};
// This is basically a wrapper for a 2D vector, to store a template of bools. (We make the vector bigger than we let on, just for safety's sake.)
class boolshapetemplate
{
public:
boolshapetemplate(); // constructor
~boolshapetemplate(); // destructor
// Accessor functions
int xsize() const { return (int)itsvector.size() - 1; };
void setxsize(int amount) { itsvector.resize(amount + 1); };
int ysize() const { return (int)itsvector[0].size() - 1; };
void setysize(int amount)
{
for (int n = 0; n < (int)itsvector.size(); n++)
itsvector[n].resize(amount + 1);
};
bool point(int x, int y) const { return itsvector[x][y]; }
void setpoint(int x, int y, bool amount) { itsvector[x][y] = amount; }
// Other functions
void clear();
private:
std::vector<std::vector<bool>> itsvector;
};
// Same thing, but for unsigned chars.
class byteshapetemplate
{
public:
byteshapetemplate(); // constructor
~byteshapetemplate(); // destructor
// Accessor functions
int xsize() const { return (int)itsvector.size() - 1; };
void setxsize(int amount) { itsvector.resize(amount + 1); };
int ysize() const { return (int)itsvector[0].size() - 1; };
void setysize(int amount)
{
for (int n = 0; n < (int)itsvector.size(); n++)
itsvector[n].resize(amount + 1);
};
unsigned char point(int x, int y) const { return itsvector[x][y]; }
void setpoint(int x, int y, unsigned char amount) { itsvector[x][y] = amount; }
// Other functions
void clear();
private:
std::vector<std::vector<unsigned char>> itsvector;
};
#endif /* classes_hpp */