ScummVM API documentation
animframe.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_ANIMFRAME_H
32 #define CRAB_ANIMFRAME_H
33 
34 #include "crab/Rectangle.h"
35 #include "crab/vectors.h"
36 #include "crab/animation/shadow.h"
37 
38 namespace Crab {
39 
40 namespace pyrodactyl {
41 namespace anim {
42 struct AnimFrame {
43  // Portion of sprite to show
44  Rect _clip;
45 
46  // The duration for which the frame must be repeated on screen
47  uint32 _repeat;
48 
49  // The anchor point of the frame
50  Vector2i _anchor;
51 
52  // The vulnerable hit box for this frame
53  Rect _boxV;
54 
55  AnimFrame() {
56  _repeat = 0;
57  }
58 
59  void load(rapidxml::xml_node<char> *node, const Rect &VBOX,
60  const uint32 &REP = 0, const int &AX = 0, const int &AY = 0);
61 };
62 
64  // The global vulnerable hit box for all the frames
65  // If the W or H of this is 0, then use individual frame values
66  Rect _boxV;
67 
68 public:
69  // The frames for the animation
71 
72  // The currentClip
73  uint _currentClip;
74 
75  // Should we flip the images in the frame rectangle?
76  TextureFlipType _flip;
77 
78  // The global repeat value for all the frames
79  // If this is 0, then use individual frame values
80  uint32 _repeat;
81 
82  // The global anchor value for all the frames
83  // If this is 0, then use individual frame values
84  Vector2i _anchor;
85 
86  // true if animation starts at a random frame
87  // used for idle animations so that every sprite doesn't animate in sync
88  bool _random;
89 
90  // Does this set of animation frames need a specific shadow offset?
91  ShadowOffset _shadow;
92 
93  AnimationFrames() {
94  reset();
95  _flip = FLIP_NONE;
96  _repeat = 0;
97  _random = false;
98  }
99  void reset() {
100  _currentClip = 0;
101  }
102 
103  void load(rapidxml::xml_node<char> *node);
104 
105  bool updateClip();
106  const AnimFrame &currentFrame();
107 };
108 } // End of namespace anim
109 } // End of namespace pyrodactyl
110 
111 } // End of namespace Crab
112 
113 #endif // CRAB_ANIMFRAME_H
Definition: Rectangle.h:42
Definition: array.h:52
Definition: animframe.h:63
Definition: moveeffect.h:37
Definition: animframe.h:42