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
|
#ifndef OYUNCU_H
#define OYUNCU_H
#include <raylib.h>
#include "sprite-animator.h"
#include "def.h"
#include "matematik.h"
#define PLAYER_SPEED_NORMAL 40
#define PLAYER_SPEED_SPRINT 65
/* enum player_states { */
/* PS_STANDING = 1, */
/* PS_WALKING = 2, */
/* PS_RUNNING = 4, */
/* PS_MOVE_STATE = PS_STANDING | PS_WALKING | PS_RUNNING, */
/* PS_CAN_MOVE = 8, */
/* PS_IFRAME_ACTIVE = 16 */
/* }; */
#define PS_STANDING 0
#define PS_WALKING 1
#define PS_RUNNING 2
typedef struct {
unsigned int move : 2;
unsigned int can_move : 1;
unsigned int iframe_active : 1;
unsigned int alive : 1;
} player_state_t;
typedef struct Player {
Vector2 position;
Vector2 direction;
int speed;
int health;
int health_max;
Rectangle hitbox;
float iframe_duration;
float iframe_duration_max;
animation_player_t animation;
Camera2D camera;
player_state_t state;
} player_t;
void input_player_direction(player_t *p);
void update_player(player_t *p, float dt);
void draw_player(player_t *p);
player_t make_player(Texture2D *texture);
int take_damage(player_t *p, int amount);
typedef enum SpriteDirections {
SP_NORTH,
SP_NORTH_EAST,
SP_EAST,
SP_SOUTH_EAST,
SP_SOUTH,
SP_SOUTH_WEST,
SP_WEST,
SP_NORTH_WEST,
} sprite_dir_enum;
sprite_dir_enum get_dir(int index);
#endif
|