forked from arvindrajayadav/Good-Robot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TMXLayer.h
82 lines (68 loc) · 1.52 KB
/
TMXLayer.h
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
#pragma once
#include "master.h"
#include "common_header.h"
#include "TileInfo.h"
namespace pyrodactyl
{
template<typename T>
void cyclic_roll_anticlockwise(T &a, T &b, T &c, T &d)
{
T temp = a;
a = b;
b = c;
c = d;
d = temp;
}
template<typename T>
void cyclic_roll_clockwise(T &a, T &b, T &c, T &d)
{
T temp = d;
d = c;
c = b;
b = a;
a = temp;
}
class Layer
{
public:
//Name of the layer
std::string name;
//Dimensions of the layer in terms of tiles
int w, h;
Layer() { w = 0; h = 0; }
bool Load(rapidxml::xml_node<char> *node);
};
//Currently we just use one general purpose layer object instead of multiple inherited classes and stuff
class MapLayer : public Layer
{
enum LayerVariant
{
V_NONE,
V_XFLIP,
V_YFLIP,
V_TRANSPOSE,
V_CLOCKWISE,
V_ANTICLOCKWISE,
V_ANTITRANSPOSE,
V_TOTAL
};
//For EXTRA RANDOM FUN, we flip the orientation of the map in one of 6 ways
//This makes it 7 possible variations of a single map (including the non-flipped version)
LayerVariant variant;
//Sometimes pesky "game designers" want to restrict some flip types
//Find out which ones we're allowed to have
bool allowed_flip[V_TOTAL];
void ApplyVariant();
public:
//The tiles in the layer
TileInfo tile[PAGE_SIZE][PAGE_SIZE];
MapLayer()
{
variant = V_NONE;
//Assume every flip is allowed until told otherwise
for (int i = 0; i < V_TOTAL; ++i)
allowed_flip[i] = true;
}
bool Load(const std::string &path, rapidxml::xml_node<char> *node);
};
}