From a472dc51a18ad16bd8c72337023a08251a5888a8 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Wed, 6 Mar 2019 21:30:57 +0100 Subject: Updated Object writing to framebuffer cObject now handles writing itself to the framebuffer with write() instead of passing the cScreen pointer to cObjectHandler --- src/cObject.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/cObject.cpp') diff --git a/src/cObject.cpp b/src/cObject.cpp index 7dc194c..217affc 100644 --- a/src/cObject.cpp +++ b/src/cObject.cpp @@ -32,6 +32,21 @@ sObject cObject::getObject() { return sObject{pos, wColor, cScreen, sizeX, sizeY}; } +void cObject::write(cRender *_render, sPos _cameraPosition) +{ + if(!bSizeSet) + return; + + for (int o = 0; o < sizeY; o++) { //y axis + for (int p = 0; p < sizeX; p++) { //x axis + if (cScreen[p][o]) { //Dont overwrite empty pixels + sPos npos{ pos.x + p - _cameraPosition.x, + pos.y + o - _cameraPosition.y }; + _render->drawPoint(cScreen[p][o], npos, true, wColor[p][o]); + } + } + } +} //protected cObject::cObject() : pos({0,0}) , bSizeSet(false){} -- cgit v1.2.3