1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #include "GameObject.h"
- Richtung invert( Richtung r )
- {
- if( r == OBEN )
- return UNTEN;
- if( r == UNTEN )
- return OBEN;
- if( r == LINKS )
- return RECHTS;
- if( r == RECHTS )
- return LINKS;
- return r;
- }
- Richtung getRichtungFromString( Text str )
- {
- if( str.istGleich( "OBEN" ) )
- return OBEN;
- if( str.istGleich( "LINKS" ) )
- return LINKS;
- if( str.istGleich( "UNTEN" ) )
- return UNTEN;
- if( str.istGleich( "RECHTS" ) )
- return RECHTS;
- return MITTE;
- }
- 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;
- }
- 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 )
- {
- 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;
- }
|