1 | /* |
2 | Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com> |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or |
7 | (at your option) any later version. |
8 | */ |
9 | |
10 | #ifndef ANIMATION_H |
11 | #define ANIMATION_H |
12 | |
13 | #include <QPointF> |
14 | #include <QList> |
15 | #include <QQueue> |
16 | #include <QObject> |
17 | #include "spritefwd.h" |
18 | |
19 | class Animation : public QObject |
20 | { |
21 | Q_OBJECT |
22 | public: |
23 | virtual ~Animation(); |
24 | |
25 | virtual void start(int t) = 0; |
26 | virtual bool step(int t) = 0; |
27 | public slots: |
28 | virtual void stop() = 0; |
29 | signals: |
30 | void over(); |
31 | }; |
32 | |
33 | class PauseAnimation : public Animation |
34 | { |
35 | Q_OBJECT |
36 | int m_time; |
37 | int m_start; |
38 | public: |
39 | PauseAnimation(int time); |
40 | |
41 | virtual void start(int t); |
42 | virtual bool step(int t); |
43 | virtual void stop() { } |
44 | }; |
45 | |
46 | class FadeAnimation : public Animation |
47 | { |
48 | Q_OBJECT |
49 | SpritePtr m_sprite; |
50 | double m_from; |
51 | double m_to; |
52 | int m_time; |
53 | int m_start; |
54 | |
55 | bool m_stopped; |
56 | public: |
57 | FadeAnimation(const SpritePtr& sprite, double from, double to, int time); |
58 | |
59 | virtual void start(int t); |
60 | virtual bool step(int t); |
61 | virtual void stop(); |
62 | }; |
63 | |
64 | class MovementAnimation : public Animation |
65 | { |
66 | Q_OBJECT |
67 | SpritePtr m_sprite; |
68 | QPointF m_from; |
69 | QPointF m_velocity; |
70 | int m_time; |
71 | int m_last; |
72 | public: |
73 | MovementAnimation(const SpritePtr& sprite, const QPointF& from, |
74 | const QPointF& velocity, int time); |
75 | |
76 | virtual void start(int t); |
77 | virtual bool step(int t); |
78 | virtual void stop(); |
79 | }; |
80 | |
81 | |
82 | class AnimationGroup : public Animation |
83 | { |
84 | Q_OBJECT |
85 | typedef QList<Animation*> List; |
86 | List m_animations; |
87 | int m_last; |
88 | public: |
89 | AnimationGroup(); |
90 | |
91 | void add(Animation* animation); |
92 | |
93 | virtual void start(int t); |
94 | virtual bool step(int t); |
95 | virtual void stop(); |
96 | }; |
97 | |
98 | class AnimationSequence : public Animation |
99 | { |
100 | Q_OBJECT |
101 | QQueue<Animation*> m_animations; |
102 | int m_last; |
103 | public: |
104 | AnimationSequence(); |
105 | |
106 | void add(Animation* animation); |
107 | |
108 | virtual void start(int t); |
109 | virtual bool step(int t); |
110 | virtual void stop(); |
111 | }; |
112 | |
113 | #endif // ANIMATION_H |
114 | |
115 | |