-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_structs.hpp
More file actions
84 lines (69 loc) · 1.25 KB
/
game_structs.hpp
File metadata and controls
84 lines (69 loc) · 1.25 KB
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
#pragma once
#include <tonc.h>
// Game is never small enough to not benefit from Vec2
struct Vec2i {
int x, y;
};
enum {
IMG_OP_NOP,
IMG_OP_BLT8,
IMG_OP_END,
IMG_OP_EVEN,
IMG_OP_ODD,
IMG_OP_SKIP8,
IMG_OP_SKIP16,
};
struct ImageAnim {
uint8_t const** frames;
uint8_t num_frames;
};
struct SpriteSpan {
int start, count;
uint8_t const* data;
};
struct SpriteFrame {
SpriteSpan const* spans;
};
struct SpriteAnim {
SpriteFrame const* frames;
uint8_t num_frames;
};
enum AnimKind {
ANIM_IDLE,
ANIM_WALK,
ANIM_ATTK,
ANIM_DEAD,
};
enum {
AI_IDLE,
AI_PRST,
AI_ATTK,
};
struct Sprite {
SpriteAnim const* anims;
};
struct Anchor {
int16_t x, y;
uint16_t dir;
};
struct Entity {
int x, y, half_width, height;
//COLOR color;
uint8_t class_;
int x_cam, y_cam;
int16_t scr_x1, scr_x2;
uint8_t state, frame, sub_frame;
uint8_t see_player, ai_state, attk_cooldown;
enum { SUBFRAMES_PER_FRAME = 6 };
void StartAnim(uint8_t new_state) {
state = new_state;
frame = 0;
sub_frame = 0;
}
};
struct Map {
uint8_t const* tiles;
Entity const* entities;
uint8_t w, h, num_sprites;
uint16_t x_start, y_start;
};