diff options
Diffstat (limited to 'cObject.cpp')
-rw-r--r-- | cObject.cpp | 74 |
1 files changed, 51 insertions, 23 deletions
diff --git a/cObject.cpp b/cObject.cpp index 8b18e41..118fe6f 100644 --- a/cObject.cpp +++ b/cObject.cpp @@ -2,6 +2,50 @@ cObject::cObject(int _sx, int _sy) { + bSizeSet = false; + + setSize(_sx, _sy); +} + +cObject::~cObject() +{ + destruct(); +} + +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}; +} + +//protected +cObject::cObject() +{ + bSizeSet = false; +} + +void cObject::setSize(int _sx, int _sy) +{ + if(bSizeSet) + return; + bBlockRender = true; //Block inherited render capabilities of parent sizeX = _sx; @@ -22,10 +66,15 @@ cObject::cObject(int _sx, int _sy) wColor[o][i] = _COL_DEFAULT; } } + + bSizeSet = true; } -cObject::~cObject() +void cObject::destruct() { + if(!bSizeSet) + return; + for (int i = 0; i < sizeX; i++) { free(cScreen[i]); free(wColor[i]); @@ -33,27 +82,6 @@ cObject::~cObject() 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}; + bSizeSet = false; } |