summaryrefslogtreecommitdiff
path: root/AmpelJonas/cObject.cpp
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2016-09-25 18:38:34 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2016-09-25 18:38:34 +0200
commit2c12d19204aa198bf8537bcdb137b40f0c7317e9 (patch)
tree2b0ea3e0feb0df50449fdd99e0b1dfa3a2f82c16 /AmpelJonas/cObject.cpp
downloadtermgl-2c12d19204aa198bf8537bcdb137b40f0c7317e9.tar.gz
Initial
Diffstat (limited to 'AmpelJonas/cObject.cpp')
-rw-r--r--AmpelJonas/cObject.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/AmpelJonas/cObject.cpp b/AmpelJonas/cObject.cpp
new file mode 100644
index 0000000..8b18e41
--- /dev/null
+++ b/AmpelJonas/cObject.cpp
@@ -0,0 +1,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};
+}