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 | |
parent | 8134a14d6e3e7f07ba2fbbc2d657789ce441fbc6 (diff) | |
download | termgl-4912eb6946734a540a81cef97bcf0d418b73406f.tar.gz |
a
-rw-r--r-- | cObject.h | 4 | ||||
-rw-r--r-- | cObjectHandler.cpp | 10 |
2 files changed, 8 insertions, 6 deletions
@@ -30,9 +30,9 @@ public: sObject getObject(); - virtual void onClick(sPos _pos, unsigned int _button){}; + virtual void onClick(sPos _pos, unsigned int _button){} - virtual void onChar(unsigned char _c){}; + virtual void onChar(unsigned char _c){} protected: //For child classes cObject(); 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; |