-
Notifications
You must be signed in to change notification settings - Fork 0
/
qtneko.h
60 lines (47 loc) · 1.13 KB
/
qtneko.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef QTNEKO_H
#define QTNEKO_H
#include <QGraphicsView>
#include <QLabel>
#include <QTimer>
#include <QPixmap>
#include <QMap>
#include <QVector>
#include <QPair>
class QGraphicsScene;
class QGraphicsPixmapItem;
struct SpriteOffsets
{
QMap<QString, QVector<QPair<int, int>>> sets;
};
class CatWidget : public QGraphicsView
{
Q_OBJECT
public:
explicit CatWidget(QWidget *parent = nullptr);
protected:
void contextMenuEvent(QContextMenuEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
private slots:
void updateFrame();
private:
QGraphicsScene *scene;
QGraphicsPixmapItem *spriteItem;
QPixmap spriteSheet;
SpriteOffsets spriteSets;
qreal nekoPosX = 100;
qreal nekoPosY = 100;
qreal mousePosX = 0;
qreal mousePosY = 0;
qreal nekoSpeed = 10;
int frameCount = 0;
int idleTime = 0;
QString idleAnimation;
int idleAnimationFrame = 0;
QTimer *timer = nullptr;
void frame();
void idle();
void resetIdleAnimation();
void setSprite(const QString &name, int frameIndex);
void updateWindowPosition();
};
#endif // QTNEKO_H