Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Author: Olli Luukas
- * Contact: olli.luukas@gmail.com
- * Date: 3.10.2010
- */
- #include "wall.h"
- Wall::Wall(int height, int width)
- {
- this->_height = height;
- this->_width = width;
- }
- Wall::Wall(int height, int width, QPoint pos)
- {
- this->_height = height;
- this->_width = width;
- this->_pos = pos;
- }
- void Wall::draw(QPainter *p)
- {
- p->drawRect(this->_pos.x(), this->_pos.y(), this->_width, this->_height);
- }
- /**
- * Author: Olli Luukas
- * Contact: olli.luukas@gmail.com
- * Date: 3.10.2010
- */
- #ifndef WALL_H
- #define WALL_H
- #include "gameobject.h"
- class Wall : public GameObject
- {
- Q_OBJECT
- public:
- Wall(int height, int width);
- Wall(int height, int width, QPoint pos);
- void draw(QPainter *p);
- };
- #endif // WALL_H
- /**
- * Author: Olli Luukas
- * Contact: olli.luukas@gmail.com
- * Date: 30.9.2010
- */
- #include "gameobject.h"
- GameObject::GameObject(QObject *parent) :
- QObject(parent)
- {
- this->_height = 4;
- this->_width = 4;
- }
- GameObject::GameObject(int height, int width, QObject *parent) :
- QObject(parent)
- {
- this->_height = height;
- this->_width = width;
- }
- /**
- * Author: Olli Luukas
- * Contact: olli.luukas@gmail.com
- * Date: 30.9.2010
- */
- #ifndef GAMEOBJECT_H
- #define GAMEOBJECT_H
- #include <QObject>
- #include <QPoint>
- #include <QPainter>
- class GameObject : public QObject
- {
- Q_OBJECT
- public:
- explicit GameObject(QObject *parent = 0);
- explicit GameObject(int height, int width, QObject *parent = 0);
- virtual void draw(QPainter *p) = 0;
- inline void setHeight(int height) { _height = height; }
- inline int getHeight() { return _height; }
- inline void setWidth(int width) { _width = width; }
- inline int getWidth() { return _width; }
- virtual inline void setPosition(QPoint pos) { _pos = pos; }
- virtual inline QPoint getPosition() { return _pos; }
- signals:
- public slots:
- protected:
- int _height;
- int _width;
- QPoint _pos;
- };
- #endif // GAMEOBJECT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement