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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#ifndef obj_h
#define obj_h
#include "rect.h"
struct App;
struct Map;
struct Renderer;
struct World;
typedef enum {
face_left,
face_right
} Face;
#define specials_xmacro \
x(special_gun, 21, 0)
typedef enum {
#define x(name, x, y) name,
specials_xmacro
#undef x
special_count
} Special;
typedef struct {
int x, y, vx, vy;
int frame;
int anim;
int grounded, headbutted, on_ramp, jumping;
int cooldown, slashing;
int inv, hp, charge;
Face face;
Rect rect;
Special spec;
} Player;
void init_player(Player* p);
void update_player(
Player* p,
struct World* w,
const struct App* app,
const struct Map* map
);
void ren_player(const Player* p, struct Renderer* r);
typedef struct {
int x, y, w;
int life;
} Laser;
void init_laser(Laser* l);
void activate_laser(Laser* l, int x, int y);
void update_laser(Laser* l);
void ren_laser(const Laser* l, struct Renderer* r);
typedef struct {
int x, y;
int frame, anim;
int bmp;
Rect rect;
} Particle;
void init_particle(Particle* p, int x, int y, int anim, int bmp);
int update_particle(Particle* p);
void ren_particle(const Particle* p, struct Renderer* r);
#define effect_max 32
typedef struct {
int x[effect_max];
int y[effect_max];
int vx[effect_max];
int vy[effect_max];
int c, life;
} Effect;
void init_effect(Effect* e, int x, int y, int vx, int vy, int c);
int update_effect(Effect* e);
void ren_effect(const Effect* e, struct Renderer* r);
typedef enum {
enemy_demon
} Enemy_Type;
typedef struct {
Enemy_Type t;
int x, y, vx, vy;
int hp, frame, anim;
int grounded, headbutted, on_ramp;
int state, inv;
Face face;
Rect rect;
} Enemy;
void init_enemy(Enemy* e, Enemy_Type t, int x, int y);
int update_enemy(Enemy* e, struct World* w);
void ren_enemy(const Enemy* e, struct Renderer* r);
void get_enemy_rect(Enemy_Type t, Rect* d);
typedef struct {
Rect r;
int vx, vy;
int hp, life, friendly;
} Deathzone;
void init_deathzone(
Deathzone* d,
const Rect* r,
int vx,
int vy,
int hp,
int life,
int friendly
);
int update_deathzone(Deathzone* d);
void ren_hud(const struct World* w, struct Renderer* r);
#endif
|