|
@@ -9,6 +9,7 @@ GameObject::GameObject( VariableTyp typ, int x, int y, int width, int height )
|
|
|
this->y = (float)y;
|
|
|
w = (float)width;
|
|
|
h = (float)height;
|
|
|
+ intersectable = 1;
|
|
|
}
|
|
|
|
|
|
void GameObject::setX( float x )
|
|
@@ -33,6 +34,8 @@ void GameObject::setHeight( float height )
|
|
|
|
|
|
bool GameObject::intersectsWith( GameObject *zObj )
|
|
|
{
|
|
|
+ if( !intersectable || !zObj->intersectable )
|
|
|
+ return 0;
|
|
|
return x < zObj->x + zObj->w && x + w > zObj->x && y < zObj->y + zObj->h && y + h > zObj->y;
|
|
|
}
|
|
|
|
|
@@ -56,6 +59,11 @@ float GameObject::getHeight() const
|
|
|
return h;
|
|
|
}
|
|
|
|
|
|
+bool GameObject::isIntersectable() const
|
|
|
+{
|
|
|
+ return intersectable;
|
|
|
+}
|
|
|
+
|
|
|
float GameObject::abstandZu( GameObject *zObj )
|
|
|
{
|
|
|
return ( Vec2<float>( x + w / 2, y + h / 2 ) - Vec2<float>( zObj->x + zObj->w / 2, zObj->y + zObj->h / 2 ) ).getLength();
|