-
Notifications
You must be signed in to change notification settings - Fork 0
/
WorldObjects.h
executable file
·68 lines (51 loc) · 1.26 KB
/
WorldObjects.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
#ifndef _H_WORLDOBJECTS
#define _H_WORLDOBJECTS
#include <windows.h>
class CEntity
{
public:
long GetX( ) { return _point.x; }
long GetY( ) { return _point.y; }
void SetX(long x) { _point.x = x; }
void SetY(long y) { _point.y = y; }
void Left () { _point.x -= 1; }
void Right() { _point.x += 1; }
void Up () { _point.y -= 1; }
void Down () { _point.y += 1; }
POINT const * GetPointReference() { return &_point; }
private:
POINT _point;
};
class CPlayer : public CEntity
{
};
#define ERROR 0
#define EMPTY 1
#define BOX 2
class CBoard
{
public:
CBoard() : _board(NULL), _width(0), _height(0) { }
~CBoard()
{
delete _board;
}
char Get (int x, int y) { if (x >= _width || x < 0 || y >= _height || y < 0) return ERROR; else return _board[x + _width * y]; }
void Set (int x, int y, char val) { _board[x + _width * y] = val; }
int Width () { return _width; }
int Height() { return _height; }
void RandomSpace(int & x, int & y);
void Size(int width, int height);
void PopulateBoxes(float flDensity);
void Clear()
{
for (int i = 0; i < _width; i++)
for (int n = 0; n < _height; n++)
Set(i, n, EMPTY);
}
private:
char * _board;
int _width;
int _height;
};
#endif