blob: 3c2eade83182ebb81512f799eb686c9456b52336 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#ifndef SPRITE_H_70503825
#define SPRITE_H_70503825
#include <deque>
#include <map>
#include <string_view>
#include <vector>
#include "direction.h"
#include "renderer.h"
#include "vector.h"
#include "step_type.h"
enum class SpriteLayer {
Normal,
Above
};
struct SpriteFrame {
SDL_Rect srcRect;
vec2i center;
vec2i size;
};
struct Animation {
bool looping = true;
std::vector<int> frameIndices;
int timerNum = 0;
};
enum class CharacterState {
Still,
Walking,
Crouching,
Running
};
enum class CharacterMedium {
Normal,
Ladder
};
struct Movement {
vec2i pos;
Direction dir;
CharacterMedium medium;
};
class Sprite {
public:
std::string alias;
bool persistent = false;
bool paused = false;
// Transform
vec2i loc { 0, 0 };
SpriteLayer layer = SpriteLayer::Normal;
bool collidable = false;
bool solid = false;
vec2i collisionOffset;
vec2i collisionSize;
std::string interactionScript;
std::string walkthroughScript;
std::string enclosureZone;
// Animation
bool isAnimated = false;
std::string spritesheet;
Direction dir = Direction::down;
std::string animationName = "still";
int animationId = 0;
int animationFrame = 0;
std::vector<SpriteFrame> frames;
std::vector<Animation> animations;
std::map<std::string, std::map<Direction, int>> nameDirToAnim;
bool animFinished = false;
bool hasShadow = false;
bool normallyHasShadow = false;
bool animPaused = false;
// Character
bool orientable = false;
int movementSpeed = 0; // 1 is slow (good for NPCs), 2 is Lucas's default walking speed
std::vector<int> followers;
std::deque<Movement> trail;
CharacterState characterState = CharacterState::Still;
CharacterMedium characterMedium = CharacterMedium::Normal;
Direction movementDir = Direction::down;
StepType stepType = StepType::none;
int runningSfxChannel = -1;
bool clipping = false;
// Input
bool controllable = false;
bool player = false;
// Behaviour
bool wander = false;
};
#endif /* end of include guard: SPRITE_H_70503825 */
|