summaryrefslogtreecommitdiff
path: root/cObjectHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cObjectHandler.cpp')
-rw-r--r--cObjectHandler.cpp10
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;