diff options
author | jonas <himself@jonasgunz.de> | 2019-01-03 21:19:20 +0100 |
---|---|---|
committer | jonas <himself@jonasgunz.de> | 2019-01-03 21:19:20 +0100 |
commit | 4912eb6946734a540a81cef97bcf0d418b73406f (patch) | |
tree | 83d6b5cd30e7182217c2f9b48c31de5f0a9cdd03 /cObjectHandler.cpp | |
parent | 8134a14d6e3e7f07ba2fbbc2d657789ce441fbc6 (diff) | |
download | termgl-4912eb6946734a540a81cef97bcf0d418b73406f.tar.gz |
a
Diffstat (limited to 'cObjectHandler.cpp')
-rw-r--r-- | cObjectHandler.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cObjectHandler.cpp b/cObjectHandler.cpp index 68abace..0b4bb65 100644 --- a/cObjectHandler.cpp +++ b/cObjectHandler.cpp @@ -77,11 +77,13 @@ int cObjectHandler::clickEvent(sPos _pos, unsigned int _button) return 1; if(_pos.y >= iHitMap[_pos.x].size()) return 1; - - iActiveObject = iHitMap[_pos.x][_pos.y]; //Set active object + if(objects[ iHitMap[_pos.x][_pos.y] ]) + { + iActiveObject = iHitMap[_pos.x][_pos.y]; //Set active object objects[ iHitMap[_pos.x][_pos.y] ]->onClick(_pos, _button); + } else return 1; @@ -139,9 +141,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(int x = oPos.x; x <= oPos.x + oSize.x; x++) { - for(unsigned int y = oPos.y; y <= oPos.y + oSize.y; y++) + for(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; |