Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Last active August 29, 2015 14:02
Show Gist options
  • Save KT-Yeh/7e77027b2c0f8f3e6f80 to your computer and use it in GitHub Desktop.
Save KT-Yeh/7e77027b2c0f8f3e6f80 to your computer and use it in GitHub Desktop.
#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