Last active
August 29, 2015 14:02
-
-
Save KT-Yeh/7e77027b2c0f8f3e6f80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MAN_H | |
#define MAN_H | |
#include <QObject> | |
#include <QPixmap> | |
#include <QPainter> | |
class Man : public QObject{ | |
Q_OBJECT | |
public: | |
Man(int _x, int _y): x(_x), y(_y), vx(0), vy(0) { | |
pic = new QPixmap(".\\man_stand.bmp"); | |
} | |
void setVelocity(int _vx, int _vy) { | |
vx = _vx; | |
vy = _vy; | |
} | |
void UpdatePosition() { | |
x += vx; | |
y += vy; | |
emit PositionChange(x, y); | |
} | |
void PaintMan(QPainter &painter) { | |
painter.drawPixmap(x, y, *pic); | |
} | |
signals: | |
void PositionChange(int, int); | |
private: | |
int x, y; // position | |
int vx, vy; // velocity | |
QPixmap *pic; | |
}; | |
#endif // MAN_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment