diff options
author | jonas <himself@jonasgunz.de> | 2018-12-28 15:09:41 +0100 |
---|---|---|
committer | jonas <himself@jonasgunz.de> | 2018-12-28 15:09:41 +0100 |
commit | 167abfe3746df80dd48dd65751583d97449e55f3 (patch) | |
tree | c308f70936e378eca8b68208a379e0458de934b4 /cObjectHandler.cpp | |
parent | c5af4c3057a904f2a037a624273c1c7a4b0295a5 (diff) | |
download | termgl-167abfe3746df80dd48dd65751583d97449e55f3.tar.gz |
Fixes in cObjectHandler:buildHitmap(), new Sample
Diffstat (limited to 'cObjectHandler.cpp')
-rw-r--r-- | cObjectHandler.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cObjectHandler.cpp b/cObjectHandler.cpp index f1252d3..edd021c 100644 --- a/cObjectHandler.cpp +++ b/cObjectHandler.cpp @@ -30,7 +30,7 @@ int cObjectHandler::moveObject(int _object, sPos _pos, int _mode) if (_mode == _MOVE_RELATIVE) objects[_object]->setPosition(sPos{ objPosition.x + _pos.x, objPosition.y + _pos.y }); - else if (_mode == _MOVE_ABSOULUTE) + else if (_mode == _MOVE_ABSOLUTE) objects[_object]->setPosition(_pos); buildHitmap(); @@ -117,7 +117,13 @@ void cObjectHandler::buildHitmap() { iHitMap.pop_back(); } - + for(unsigned int x = 0; x < iHitMap.size(); x++) + { + for(unsigned int y = 0; y < iHitMap[x].size(); y++) + { + iHitMap[x][y] = 0; + } + } //Write object IDs to iHitMap for(unsigned int i = 0; i < objects.size(); i++) { @@ -126,9 +132,9 @@ void cObjectHandler::buildHitmap() sPos oPos = objects[i]->getPosition(); sPos oSize = objects[i]->getSize(); - for(unsigned int x = oPos.x; x < oPos.x + oSize.x; x++) + for(unsigned int x = oPos.x; x <= oPos.x + oSize.x; x++) { - for(unsigned int y = oPos.y; y < oPos.y + oSize.y; y++) + for(unsigned int y = oPos.y; y <= oPos.y + oSize.y; y++) { if(x < size.x && y < size.y) //Objects can be outside the screen. iHitMap[x][y] = i; |