PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
simple_animator.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef SIMPLE_ANIMATOR_H
20 #define SIMPLE_ANIMATOR_H
21 
22 #include <SDL2/SDL_timer.h>
23 #include <QList>
24 #include <utility>
25 
26 typedef std::pair<double, double > AniPos;
27 
29 {
30 public:
32  SimpleAnimator(const SimpleAnimator &animator);
33  SimpleAnimator(bool enables, int framesq=1, int fspeed=64, int First=0, int Last=-1,
34  bool rev=false, bool bid=false);
35  ~SimpleAnimator();
36 
37  bool operator!=(const SimpleAnimator &animator) const;
38  bool operator==(const SimpleAnimator &animator) const;
39  SimpleAnimator &operator=(const SimpleAnimator &animator);
40 
41  void construct(bool enables=false, int framesq=1, int fspeed=64, int First=0, int Last=-1,
42  bool rev=false, bool bid=false);
43 
44  void setFrameSequance(QList<int> sequance);
45 
46  AniPos image(double frame=-1);
47 
48  void setFrame(int y);
49  void setFrames(int first, int last);
50 
51  void start();
52  void stop();
53 
54  int speed;
55 
56  static unsigned int TickAnimation(unsigned int x, void *p);
57 
58  void setOnceMode(bool once, int loops=1);
59  void manualTick(float ticks);
60  bool isFinished();
61 public:
62  void nextFrame();
63 
64 private:
65  double pos1;
66  double pos2;
67  float manual_ticks;
68  bool onceMode;
69  int onceMode_loops;
70  bool animationFinished;
71 
72  bool frame_sequance_enabled;
73  QList<int> frame_sequance;
74  int frame_sequance_cur;
75 
76  int CurrentFrame;
77 
78  bool animated;
79 
80  bool bidirectional;
81  bool reverce;
82 
83  bool isEnabled;
84  SDL_TimerID timer_id;
85 
86  double framesQ;
87 
88  //Animation alhorithm
89  int frameFirst;
90  int frameLast;
91 };
92 
93 #endif // SIMPLE_ANIMATOR_H
Definition: simple_animator.h:28