GameObject.cpp 821 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "GameObject.h"
  2. GameObject::GameObject( VariableTyp typ, int x, int y, int width, int height )
  3. : Variable( typ )
  4. {
  5. this->x = (float)x;
  6. this->y = (float)y;
  7. w = (float)width;
  8. h = (float)height;
  9. }
  10. void GameObject::setX( float x )
  11. {
  12. this->x = x;
  13. }
  14. void GameObject::setY( float y )
  15. {
  16. this->y = y;
  17. }
  18. void GameObject::setWidth( float width )
  19. {
  20. w = width;
  21. }
  22. void GameObject::setHeight( float height )
  23. {
  24. h = height;
  25. }
  26. bool GameObject::intersectsWith( GameObject *zObj )
  27. {
  28. return x < zObj->x + zObj->w && x + w > zObj->x && y < zObj->y + zObj->h && y + h > zObj->y;
  29. }
  30. float GameObject::getX() const
  31. {
  32. return x;
  33. }
  34. float GameObject::getY() const
  35. {
  36. return y;
  37. }
  38. float GameObject::getWidth() const
  39. {
  40. return w;
  41. }
  42. float GameObject::getHeight() const
  43. {
  44. return h;
  45. }