gameobject.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef GAMEOBJECT_H
  2. #define GAMEOBJECT_H
  3. #include "gamemap.h"
  4. #include <QObject>
  5. #include <QPixmap>
  6. #include <QtDebug>
  7. #include <math.h>
  8. enum Orientation {
  9. Ot_Left,
  10. Ot_Right,
  11. Ot_Up,
  12. Ot_Down
  13. };
  14. class GameMap;
  15. class GameObject : public QObject {
  16. Q_OBJECT
  17. public:
  18. explicit GameObject(QObject* parent = nullptr);
  19. QPixmap image() const;
  20. void setImage(const QPixmap& image);
  21. QRect rect() const;
  22. void setRect(const QRect& rect);
  23. QString gameObjectType() const;
  24. void setGameObjectType(const QString& gameObjectType);
  25. int x() const;
  26. void setX(int x);
  27. QList<QPixmap> downImage;
  28. QList<QPixmap> rightImage;
  29. QList<QPixmap> leftImage;
  30. QList<QPixmap> upImage;
  31. int y() const;
  32. void setY(int y);
  33. void radomMove();
  34. GameMap* map() const;
  35. void setMap(GameMap* map);
  36. void resetRect();
  37. void randomDirections();
  38. void moveRight();
  39. void moveLeft();
  40. void moveUp();
  41. void moveDown();
  42. Orientation orientation() const;
  43. void setOrientation(const Orientation& orientation);
  44. bool CaOtherGameObject(GameObject* other);
  45. bool isHitOther(GameObject* other);
  46. signals:
  47. private:
  48. QPixmap m_image;
  49. QRect m_rect;
  50. QString m_gameObjectType;
  51. int m_x;
  52. int m_y;
  53. GameMap* m_map;
  54. int m_moveX;
  55. int m_moveY;
  56. int m_pixIndex;
  57. QList<QPoint> m_directions;
  58. Orientation m_orientation;
  59. QPixmap m_defaultPix;
  60. };
  61. #endif // GAMEOBJECT_H