12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include "GameObject.h"
- #include "Punkt.h"
- GameObject::GameObject( VariableTyp typ, int x, int y, int width, int height )
- : Variable( typ )
- {
- this->x = (float)x;
- this->y = (float)y;
- w = (float)width;
- h = (float)height;
- intersectable = 1;
- }
- void GameObject::setX( float x )
- {
- this->x = x;
- }
- void GameObject::setY( float y )
- {
- this->y = y;
- }
- void GameObject::setWidth( float width )
- {
- w = width;
- }
- void GameObject::setHeight( float height )
- {
- h = 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;
- }
- float GameObject::getX() const
- {
- return x;
- }
- float GameObject::getY() const
- {
- return y;
- }
- float GameObject::getWidth() const
- {
- return w;
- }
- 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();
- }
|