ScummVM API documentation
walkframes.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_WALKFRAMES_H
32#define CRAB_WALKFRAMES_H
33
34#include "crab/timer.h"
35#include "crab/ai/movement.h"
36#include "crab/animation/animframe.h"
37#include "crab/people/personbase.h"
38
39namespace Crab {
40
41namespace pyrodactyl {
42namespace anim {
43enum WalkAnimType {
44 WT_STAND,
45 WT_WALK,
46 WT_FIGHT,
47 WT_KO,
48 WT_TOTAL
49};
50
52 struct WalkFrameSet {
53 AnimationFrames frames[DIRECTION_TOTAL];
54
55 void load(rapidxml::xml_node<char> *node) {
56 frames[DIRECTION_DOWN].load(node->first_node("down"));
57 frames[DIRECTION_UP].load(node->first_node("up"));
58 frames[DIRECTION_LEFT].load(node->first_node("left"));
59 frames[DIRECTION_RIGHT].load(node->first_node("right"));
60 }
61 };
62
63 // The walking animations of the sprite
64 WalkFrameSet _set[WT_TOTAL];
65
66 // The current walking animation
67 WalkAnimType _cur;
68
69 // The timers used for animation playing
70 Timer _timer;
71
72 // Dialog box related
73 void updateClip(WalkAnimType type, Direction d);
74
75public:
76 WalkFrames() {
77 _cur = WT_STAND;
78 _timer.start();
79 }
80 ~WalkFrames() {}
81
82 void load(rapidxml::xml_node<char> *node);
83
84 bool updateClip(Direction d, bool reset);
85 void resetClip(Direction d);
86
87 void type(WalkAnimType type) {
88 _cur = type;
89 }
90
91 WalkAnimType type() {
92 return _cur;
93 }
94
95 bool type(const Vector2f &vel, Direction &dir, const pyrodactyl::people::PersonState &pst, const bool &first_x);
96
97 const Rect &clip(Direction d) {
98 return _set[_cur].frames[d].currentFrame()._clip;
99 }
100
101 const Rect &boxV(Direction d) {
102 return _set[_cur].frames[d].currentFrame()._boxV;
103 }
104
105 const TextureFlipType &flip(Direction d) {
106 return _set[_cur].frames[d]._flip;
107 }
108
109 const ShadowOffset &shadow(Direction d) {
110 return _set[_cur].frames[d]._shadow;
111 }
112
113 int anchorX(Direction d) {
114 return _set[_cur].frames[d].currentFrame()._anchor.x;
115 }
116
117 int anchorY(Direction d) {
118 return _set[_cur].frames[d].currentFrame()._anchor.y;
119 }
120
121 // Dialog box related
122 Rect dialogClip(const pyrodactyl::people::PersonState &state);
123 void updateClip(const pyrodactyl::people::PersonState &state);
124};
125} // End of namespace anim
126} // End of namespace pyrodactyl
127
128} // End of namespace Crab
129
130#endif // CRAB_WALKFRAMES_H
Definition: timer.h:43
Definition: animframe.h:63
Definition: walkframes.h:51
Definition: Rectangle.h:42