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
19class Animation : public QObject
20{
21Q_OBJECT
22public:
23 virtual ~Animation();
24
25 virtual void start(int t) = 0;
26 virtual bool step(int t) = 0;
27public slots:
28 virtual void stop() = 0;
29signals:
30 void over();
31};
32
33class PauseAnimation : public Animation
34{
35Q_OBJECT
36 int m_time;
37 int m_start;
38public:
39 PauseAnimation(int time);
40
41 virtual void start(int t);
42 virtual bool step(int t);
43 virtual void stop() { }
44};
45
46class FadeAnimation : public Animation
47{
48Q_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;
56public:
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
64class MovementAnimation : public Animation
65{
66Q_OBJECT
67 SpritePtr m_sprite;
68 QPointF m_from;
69 QPointF m_velocity;
70 int m_time;
71 int m_last;
72public:
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
82class AnimationGroup : public Animation
83{
84Q_OBJECT
85 typedef QList<Animation*> List;
86 List m_animations;
87 int m_last;
88public:
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
98class AnimationSequence : public Animation
99{
100Q_OBJECT
101 QQueue<Animation*> m_animations;
102 int m_last;
103public:
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