aboutsummaryrefslogtreecommitdiff
path: root/src/cObject.cpp
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-03-07 01:06:25 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-03-07 01:06:25 +0100
commit99249ba62bcdfbe300c6ab7db02088d8d1e118c4 (patch)
treec90f707b593d3d2ff3ba2e06aadadf10da35a696 /src/cObject.cpp
parent91312efb1490e899f8800c965865c8095f31f350 (diff)
downloadtermgl-99249ba62bcdfbe300c6ab7db02088d8d1e118c4.tar.gz
Switched to unsigned cariables for all counting loops and buffer accesses
Diffstat (limited to 'src/cObject.cpp')
-rw-r--r--src/cObject.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/cObject.cpp b/src/cObject.cpp
index bba7509..19f485f 100644
--- a/src/cObject.cpp
+++ b/src/cObject.cpp
@@ -27,22 +27,16 @@ void cObject::setPosition(int _x, int _y)
pos.y = _y;
}
-
-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
+ for (unsigned int o = 0; o < sizeY; o++) { //y axis
+ for (unsigned 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 };
+ sPos npos{ pos.x + (int)p - _cameraPosition.x,
+ pos.y + (int)o - _cameraPosition.y };
_render->drawPoint(cScreen[p][o], npos, true, wColor[p][o]);
}
}
@@ -71,8 +65,8 @@ void cObject::setSize(unsigned int _sx, unsigned int _sy)
for (unsigned 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++) {
+ for (unsigned int i = 0; i < sizeY; i++) {
+ for (unsigned int o = 0; o < sizeX; o++) {
cScreen[o][i] = 0;
wColor[o][i] = _COL_DEFAULT;
}
@@ -86,7 +80,7 @@ void cObject::destruct()
if(!bSizeSet)
return;
- for (int i = 0; i < sizeX; i++) {
+ for (unsigned int i = 0; i < sizeX; i++) {
free(cScreen[i]);
free(wColor[i]);
}