blob: 8b18e4158ef1191e3101f02366ac7f81401af1e3 (
plain)
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
|
#include "cObject.h"
cObject::cObject(int _sx, int _sy)
{
bBlockRender = true; //Block inherited render capabilities of parent
sizeX = _sx;
sizeY = _sy;
//Initialize 2D array
cScreen = (char**) malloc(sizeof *cScreen * _sx);
for (int i = 0; i < _sx; i++)
cScreen[i] = (char*)malloc(sizeof *cScreen[i] * _sy);
wColor = (WORD**)malloc(sizeof *wColor * _sx);
for (int i = 0; i < _sx; i++)
wColor[i] = (WORD*)malloc(sizeof *wColor[i] * _sy);
for (int i = 0; i < sizeY; i++) {
for (int o = 0; o < sizeX; o++) {
cScreen[o][i] = NULL;
wColor[o][i] = _COL_DEFAULT;
}
}
}
cObject::~cObject()
{
for (int i = 0; i < sizeX; i++) {
free(cScreen[i]);
free(wColor[i]);
}
free(cScreen);
free(wColor);
}
sPos cObject::getPosition()
{
return pos;
}
void cObject::setPosition(sPos _pos)
{
pos = _pos;
}
void cObject::setPosition(int _x, int _y)
{
pos.x = _x;
pos.y = _y;
}
sObject cObject::getObject()
{
return sObject{pos, wColor, cScreen, sizeX, sizeY};
}
|