Advertisement
Guest User

Untitled

a guest
Jun 18th, 2017
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1. /**
  2.  * Author: Olli Luukas
  3.  * Contact: olli.luukas@gmail.com
  4.  * Date: 3.10.2010
  5.  */
  6.  
  7. #include "wall.h"
  8.  
  9. Wall::Wall(int height, int width)
  10. {
  11.   this->_height = height;
  12.   this->_width = width;
  13. }
  14. Wall::Wall(int height, int width, QPoint pos)
  15. {
  16.   this->_height = height;
  17.   this->_width = width;
  18.   this->_pos = pos;
  19. }
  20.  
  21. void Wall::draw(QPainter *p)
  22. {
  23.   p->drawRect(this->_pos.x(), this->_pos.y(), this->_width, this->_height);
  24. }
  25.  
  26. /**
  27.  * Author: Olli Luukas
  28.  * Contact: olli.luukas@gmail.com
  29.  * Date: 3.10.2010
  30.  */
  31.  
  32. #ifndef WALL_H
  33. #define WALL_H
  34.  
  35. #include "gameobject.h"
  36.  
  37. class Wall : public GameObject
  38. {
  39.   Q_OBJECT
  40. public:
  41.     Wall(int height, int width);
  42.     Wall(int height, int width, QPoint pos);
  43.     void draw(QPainter *p);
  44. };
  45.  
  46. #endif // WALL_H
  47.  
  48. /**
  49.  * Author: Olli Luukas
  50.  * Contact: olli.luukas@gmail.com
  51.  * Date: 30.9.2010
  52.  */
  53.  
  54. #include "gameobject.h"
  55.  
  56. GameObject::GameObject(QObject *parent) :
  57.     QObject(parent)
  58. {
  59.   this->_height = 4;
  60.   this->_width = 4;
  61. }
  62. GameObject::GameObject(int height, int width, QObject *parent) :
  63.     QObject(parent)
  64. {
  65.   this->_height = height;
  66.   this->_width = width;
  67. }
  68.  
  69. /**
  70.  * Author: Olli Luukas
  71.  * Contact: olli.luukas@gmail.com
  72.  * Date: 30.9.2010
  73.  */
  74.  
  75. #ifndef GAMEOBJECT_H
  76. #define GAMEOBJECT_H
  77.  
  78. #include <QObject>
  79. #include <QPoint>
  80. #include <QPainter>
  81.  
  82. class GameObject : public QObject
  83. {
  84.   Q_OBJECT
  85. public:
  86.   explicit GameObject(QObject *parent = 0);
  87.   explicit GameObject(int height, int width, QObject *parent = 0);
  88.   virtual void draw(QPainter *p) = 0;
  89.   inline void setHeight(int height) { _height = height; }
  90.   inline int getHeight() { return _height; }
  91.   inline void setWidth(int width) { _width = width; }
  92.   inline int getWidth() { return _width; }
  93.   virtual inline void setPosition(QPoint pos) { _pos = pos; }
  94.   virtual inline QPoint getPosition() { return _pos; }
  95.  
  96. signals:
  97.  
  98. public slots:
  99.  
  100. protected:
  101.   int _height;
  102.   int _width;
  103.   QPoint _pos;
  104. };
  105.  
  106. #endif // GAMEOBJECT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement