Nav apraksta

maingamewindow.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef MAINGAMEWINDOW_H
  2. #define MAINGAMEWINDOW_H
  3. #include <cmath>
  4. #include <QGraphicsView>
  5. #include <QMainWindow>
  6. #include <QGraphicsScene>
  7. #include <QBitmap>
  8. #include <QGraphicsView>
  9. #include <genericscrollingobject.h>
  10. //
  11. // Constants for the types of objects. We use them to determine what collisions are
  12. // worth processing.
  13. //
  14. const int RECT_MODE = 1;
  15. class GenericScrollingObject;
  16. typedef unsigned int uint;
  17. enum class Mode {SQUARE_TOP_LEFT, RECT_TOP_LEFT, RECT_RANDOM, PYRAMID_RANDOM};
  18. class MainGameWindow: public QMainWindow {
  19. public:
  20. MainGameWindow(uint rows, uint cols);
  21. MainGameWindow(const QString &maze);
  22. MainGameWindow(Mode gameMode);
  23. void moveRobot(char dir);
  24. bool canMove(char dir);
  25. void display(const QString &st);
  26. void display(int n);
  27. private:
  28. QGraphicsScene *s;
  29. QGraphicsView *v;
  30. uint _rows, _cols;
  31. QString _maze;
  32. GenericScrollingObject *robot;
  33. QTimer *timer;
  34. uint rowHeight, colWidth;
  35. float pct_margin;
  36. QGraphicsTextItem *msg;
  37. void paintMaze(uint initialX, uint initialY);
  38. void initMembers();
  39. bool validMaze();
  40. void createPiramid();
  41. void assignValidPos(uint &initialX, uint &initialY);
  42. void startTheTimer();
  43. void posToRC(uint &r, uint &c);
  44. char posToChar();
  45. void setMaze(const QString &maze) { _maze = maze; }
  46. };
  47. void delay(int ms);
  48. #define PCT_MARGIN 0.1
  49. #endif // MAINGAMEWINDOW_H