gamemap.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef GAMEMAP_H
  2. #define GAMEMAP_H
  3. #include "gameobject.h"
  4. #include "gamescence.h"
  5. #include <QImage>
  6. #include <QObject>
  7. #include <QPixmap>
  8. class GameObject;
  9. class GameScence;
  10. class GameMap : public QObject {
  11. Q_OBJECT
  12. public:
  13. explicit GameMap(QObject* parent = nullptr);
  14. int cols() const;
  15. void setCols(int cols);
  16. int rows() const;
  17. void setRows(int rows);
  18. int step() const;
  19. void setStep(int step);
  20. virtual QImage drawScence();
  21. virtual bool play();
  22. QList<GameObject*> gameObjects;
  23. void addGameObject(GameObject* obj);
  24. bool hasObjectInPostion(GameObject* selObj, int x, int y, int n = 0);
  25. bool isOverLap(const QRect& rc1, const QRect& rc2, int n = 0);
  26. GameObject* hero() const;
  27. void setHero(GameObject* hero);
  28. bool isStop() const;
  29. void setIsStop(bool isStop);
  30. GameScence* scence() const;
  31. void setScence(GameScence* scence);
  32. GameObject* exitDoor() const;
  33. void setExitDoor(GameObject* exitDoor);
  34. virtual void initGame();
  35. virtual void startGame();
  36. signals:
  37. void onSuccessed(int ret);
  38. void onFailed(int ret);
  39. private:
  40. int m_cols;
  41. int m_rows;
  42. int m_step;
  43. QPoint m_focusPoint;
  44. GameObject* m_hero;
  45. GameScence* m_scence;
  46. GameObject* m_exitDoor;
  47. bool m_isStop;
  48. };
  49. #endif // GAMEMAP_H