-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map.h
101 lines (77 loc) · 1.55 KB
/
Map.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once
#include <fstream>
#include <vector>
#include "Data.h"
namespace olc
{
class Sprite;
}
class cEngine;
class cDynamic;
class cMap
{
protected:
int* m_nIndices;
int* m_nIndices2;
int* m_nIndices3;
bool* m_bSolids;
bool* m_bIsAnimated;
bool WithinBoundaries(int x, int y)
{
if (x < 0 || y < 0 || x > nLevelWidth - 1 || y > nLevelHeight - 1)
return false;
return true;
}
public:
std::string sName;
int nLevelWidth;
int nLevelHeight;
bool bHasBeenEntered;
std::vector<cDynamic*> vecDyn;
void RemoveDynamic(unsigned x);
olc::Sprite* sprite;
int GetIndex(int x, int y)
{
if (WithinBoundaries(x, y))
return m_nIndices[y * nLevelWidth + x];
else
return 0;
};
int GetIndex2(int x, int y)
{
if (WithinBoundaries(x, y))
return m_nIndices2[y * nLevelWidth + x];
else
return 0;
};
int GetIndex3(int x, int y)
{
if (WithinBoundaries(x, y))
return m_nIndices3[y * nLevelWidth + x];
else
return 0;
};
bool GetSolid(int x, int y)
{
if (WithinBoundaries(x, y))
return m_bSolids[y * nLevelWidth + x];
else
return true;
};
bool GetIsAnimated(int x, int y)
{
if (WithinBoundaries(x, y))
return m_bIsAnimated[y * nLevelWidth + x];
else
return false;
}
bool Create(std::wstring filepath, std::string name, olc::Sprite* sprite);
virtual void PopulateDynamics()
{
return;
}
virtual void FirstEnter() { bHasBeenEntered = true; }
cEngine* engine;
cMap(cEngine* _engine);
~cMap();
};