summaryrefslogtreecommitdiff
path: root/src/cObject.cpp
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-03-06 21:30:57 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-03-06 21:30:57 +0100
commita472dc51a18ad16bd8c72337023a08251a5888a8 (patch)
treee9440f7c00fafdb7826b960e7cb4c59d4723546e /src/cObject.cpp
parentf8e188f2e6db9049e0c8c4e905e58aaf66e3b6cb (diff)
downloadtermgl-a472dc51a18ad16bd8c72337023a08251a5888a8.tar.gz
Updated Object writing to framebuffer
cObject now handles writing itself to the framebuffer with write() instead of passing the cScreen pointer to cObjectHandler
Diffstat (limited to 'src/cObject.cpp')
-rw-r--r--src/cObject.cpp15
1 files changed, 15 insertions, 0 deletions
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){}