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
#ifndef __PLAYER_H__
#define __PLAYER_H__
#include "list.h"
#include "vector.h"
#include "body.h"
#include "color.h"
#include "custom_utils.h"
#include "string.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
typedef struct player {
size_t player_id;
list_t *meta_bodies;
// physics state
double *ph_applied_force_magnitude;
// stats
size_t stats_kills;
size_t stats_food;
// settings
char st_left_key;
char st_right_key;
char st_boost_key;
char st_shoot_key;
color_t st_color;
// player specific state
bool turn_left;
bool turn_right;
// cooldowns
double cd_dash;
double cd_shoot;
double cd_collide_player;
// powerups
size_t pu_base_speed;
size_t pu_bullet_speed;
size_t pu_rotate_rate;
size_t pu_dash_boost;
} player_t;
player_t *player_init(size_t player_id, vector_t pos, char left_key, char right_key, char boost_key, char shoot_key);
void player_add_glow(player_t *player, size_t glow_radius);
body_t *player_get_head(player_t *p);
body_t *player_get_tail(player_t *p);
void player_set_velocity(player_t *p, double vel);
void player_turn(player_t *p);
void player_dash(player_t *p);
body_t *player_shoot(player_t *p);
void player_eat(player_t *p, body_t *food);
body_t *player_body(player_t *p);
vector_t player_head_pos(player_t *p);
vector_t player_tail_pos(player_t *p);
double player_get_score(player_t *p);
void player_update_kills(player_t *p);
void player_update_food(player_t *p);
body_t *player_add_body(player_t *p);
void player_free(void *p);
bool player_moves_on_key(player_t *p, char key);
void player_update_cd(player_t *p, double dt);
void player_update_pu(player_t *p, double dt);
void player_refresh_cd_dash(player_t *p);
void player_refresh_cd_collide_player(player_t *p);
#endif // #ifndef __PLAYER_H__