-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathso_long.h
137 lines (123 loc) · 3.33 KB
/
so_long.h
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wpepping <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/03 18:37:44 by wpepping #+# #+# */
/* Updated: 2024/08/18 17:04:09 by wpepping ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SO_LONG_H
# define SO_LONG_H
# include <stdlib.h>
# include <unistd.h>
# include <fcntl.h>
# include <sys/time.h>
# include <X11/Xlib.h>
# include <X11/keysym.h>
# include "minilibx/mlx.h"
# define TILE_WIDTH 64
# define TILE_HEIGHT 64
# define END_TILE_WIDTH 380
# define END_TILE_HEIGHT 160
# define EMPTY 48
# define WALL 49
# define COLLECTIBLE 67
# define MAPEXIT 69
# define PSTART 80
# define ESTART 78
# define ENEMY_MOVE_TIME 500
# define BULLET_SIZE 4
# define BULLET_MOVE_TIME 3
typedef struct s_coor
{
int x;
int y;
} t_coor;
typedef struct s_tilecount
{
int pstarts;
int exits;
int estarts;
} t_tilecount;
typedef struct s_textures
{
void *background;
void *player;
void *player_dead;
void *wall[3];
void *weapon[3];
void *target;
void *enemy;
void *wasted;
void *youwin;
void *bullet;
void *player_left;
void *player_up;
void *player_down;
void *enemy_dead;
} t_textures;
typedef struct s_enemy
{
long movetime;
t_coor pos;
t_coor dir;
int dead;
} t_enemy;
typedef struct s_bullet
{
long movetime;
t_coor pospix;
t_coor postile;
t_coor dir;
} t_bullet;
typedef struct s_data
{
void *mlx;
void *window;
int width;
int height;
int map_width;
int map_height;
char **map;
int collectibles;
int collected;
long end_game;
int dummy;
void *end_game_graphic;
t_enemy enemy;
t_bullet bullet;
t_textures textures;
t_coor ppos;
t_coor pdir;
} t_data;
void *ft_calloc(size_t nmemb, size_t size);
size_t ft_strlen(const char *s);
void free_map(char **map);
long currtime(void);
void copy_coor(t_coor *c1, t_coor *c2);
int handle_close(t_data *data);
int handle_input(int keycode, t_data *data);
int handle_loop(t_data *data);
void init_map(t_data *data);
void move_player(t_data *data, int x, int y);
void draw_tile(t_data *data, t_coor coor);
void draw_bullet(t_data *data, t_bullet *bullet);
int read_map(t_data *data, char *fname);
int is_valid_map(t_data *data);
int check_special_tiles(t_data *data);
void init_textures(t_data *data);
void clear_textures(t_data *data);
void ft_putendl_fd(char *s, int fd);
void get_color(t_data *data, int c[3], char *result);
void *ft_memcpy(void *dest, const void *src, size_t n);
char *get_next_line(int fd);
int update_enemy(t_data *d, t_enemy *e);
int update_bullet(t_data *d, t_bullet *b);
void end_game(t_data *data, void *image);
void shoot(t_data *data, t_bullet *bullet);
void kill_enemy(t_data *d, t_enemy *e, t_bullet *b);
int update_bullet(t_data *d, t_bullet *b);
#endif