-
Notifications
You must be signed in to change notification settings - Fork 2
/
regularmove.h
78 lines (63 loc) · 1.56 KB
/
regularmove.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef REGULARMOVE_H
#define REGULARMOVE_H
//#define ANIMATION
#ifdef ANIMATION
#include <QState>
#include <QPropertyAnimation>
#endif
#include "movable.h"
#include <QTimer>
class RegularMove : public Movable
{
Q_OBJECT
#ifdef ANIMATION
Q_PROPERTY(int frame READ frame WRITE setFrame)
Q_PROPERTY(QString basename READ _basename WRITE _setBasename);
#endif
public:
RegularMove(int x, int y, Background *parent);
virtual void update_pos()=0;
#ifdef ANIMATION
std::string direction() const;
void set_direction(std::string);
void init_animation_perso();
void init_animation_ennemi(std::string);
void positionner(int x, int y);
void show_collision() {emit collision();}
#endif
private:
#ifdef ANIMATION
void init_animation(std::string nom, int nb_frames);
QString _basename() const;
void _setBasename(QString basename);
int frame();
void setFrame(int frame);
QState* st_dr;
QState* st_ga;
QState* st_ha;
QState* st_ba;
#endif
QTimer* timer;
private slots:
void _update_pos();
#ifdef ANIMATION
signals:
void left();
void right();
void up();
void down();
void collision();
protected:
int m_frame;
QString m_basename;
QStateMachine* machine;
std::string dir;
QPropertyAnimation animation;
QPropertyAnimation mov_animation;
QState* first_state;
void add_animation(int, int, int, int, std::string);
void add_animation(QState*, int, int, int, int, std::string);
void start_animation(QState* initial=nullptr);
#endif
};
#endif // REGULARMOVE_H