PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
matrix_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 MATRIXANIMATOR_H
20 #define MATRIXANIMATOR_H
21 
22 #include <QList>
23 #include <QHash>
24 
25 #include "pointf.h"
26 #include "rectf.h"
27 #include "sizef.h"
28 #include "size.h"
29 
30 #include "player_calibration.h"
31 
33 {
34  float x;
35  float y;
36  float offset_x;
37  float offset_y;
38 };
39 
41 {
42 public:
43 
44  enum MatrixAnimates
45  {
46  Nothing=-1,
47  Idle=0,
48  Run,
49  JumpFloat,
50  JumpFall,
51  SpinJump,
52  Sliding,
53  Climbing,
54  Fire,
55  SitDown,
56  Dig,
57  GrabIdle,
58  GrabRun,
59  GrabJump,
60  GrabSitDown,
61  RacoonRun,
62  RacoonFloat,
63  RacoonFly,
64  RacoonFlyDown,
65  RacoonTail,
66  Swim,
67  SwimUp,
68  OnYoshi,
69  OnYoshiSit,
70  PipeUpDown,
71  PipeUpDownRear,
72  SlopeSlide,
73  TanookiStatue,
74  SwordAttak,
75  JumpSwordUp,
76  JumpSwordDown,
77  DownSwordAttak,
78  Hurted,
79  };
80 
82  MatrixAnimator(int _width, int _height);
84  ~MatrixAnimator();
85  void setFrameSequance(QList<MatrixAnimatorFrame > _sequence);
86  void setFrameSpeed(int speed);
87  void setDirection(int _direction, bool force=false);
88  void setSize(int _width, int _height);
89  PGE_SizeF size();
90  PGE_SizeF sizeOfFrame();
91  void tickAnimation(float frametime);
92  PGE_RectF curFrame();
93  PGE_PointF curOffset();
94  MatrixAnimates curAnimation();
95  int curFramespeed();
96 
97  void installAnimationSet(obj_player_calibration &calibration);
98  void playOnce(MatrixAnimates aniName, int _direction, int speed=-1, bool fixed_speed=false, bool locked=false, int skipLastFrames=0);
99  void unlock();
100  void switchAnimation(MatrixAnimates aniName, int _direction, int speed=-1);
101 
102  MatrixAnimates toEnum(QString aniName);
103 private:
104  void nextFrame();
105  void buildRect();
106 
107  float width;
108  float height;
109  float width_f;
110  float height_f;
111  float delay_wait;
112  int framespeed;
113  int framespeed_once;
114  int curFrameI;
115  PGE_RectF curRect;
116  PGE_PointF curOffsets;
117  typedef QList<MatrixAnimatorFrame > AniSequence;
118 
119  int direction;
120  bool once;
121  bool once_fixed_speed;
122  bool once_locked;
123  bool once_play_again;
124  int once_play_again_skip_last_frames;
125  int once_play_again_direction;
126  MatrixAnimates backup_sequance;
127  MatrixAnimates current_sequance;
128  AniSequence sequence;
129  QHash<MatrixAnimates, AniSequence > s_bank_left;
130  QHash<MatrixAnimates, AniSequence > s_bank_right;
131 
132  void buildEnums();
133  QHash<QString, MatrixAnimates > StrToEnum;
134 };
135 
136 #endif // MATRIXANIMATOR_H
Definition: matrix_animator.h:32
Definition: sizef.h:23
Definition: pointf.h:23
Definition: player_calibration.h:56
Definition: rectf.h:26
Definition: matrix_animator.h:40