-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathso_long.h
More file actions
177 lines (146 loc) · 4.38 KB
/
so_long.h
File metadata and controls
177 lines (146 loc) · 4.38 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ychaaibi <ychaaibi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/21 11:12:56 by ychaaibi #+# #+# */
/* Updated: 2022/02/06 15:47:07 by ychaaibi ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SO_LONG_H
# define SO_LONG_H
# include <stdlib.h>
# include <unistd.h>
# include <fcntl.h>
# include <mlx.h>
typedef struct s_anime
{
struct s_anime *next;
void *img;
} t_anime;
typedef struct s_player
{
int x;
int y;
int moves;
int count;
int dir;
t_anime *left_anime;
t_anime *right_anime;
t_anime *current_anime;
} t_player;
typedef struct s_enemy
{
int x;
int y;
int dir;
int width;
int height;
int exist;
int count;
int count_move;
int curr_anime_ind;
t_anime *current_anime;
t_anime *left_anime;
t_anime *right_anime;
} t_enemy;
typedef struct s_collectibe_position
{
int x;
int y;
int still;
} t_collectibe_position;
typedef struct s_collectibe
{
int x;
int y;
int count;
t_anime *current_anime;
t_anime *anime;
} t_collectibe;
typedef struct s_game
{
void *mlx;
void *window;
void *ground_img;
void *collectibe_img;
void *exit_img;
void *exit_open_img;
int w;
int width;
int h;
int height;
int collectibe_count;
int end;
int end_count;
char **map;
t_player *player;
t_enemy *enemy;
} t_game;
typedef struct s_end
{
int x;
int y;
int fin[3];
int start_x;
int start_y;
} t_end;
//_______________________Utils_______________________//
int ft_strlen(const char *s);
char *ft_substr(char const *s, unsigned int start, size_t len);
char **ft_split(char const *s, char c);
char *ft_strjoin(char const *s1, char const *s2);
size_t ft_strlcat(char *dest, char const *src, size_t size);
char *ft_itoa(int n);
void *ft_calloc(size_t count, size_t size);
int ft_strcmp(char *s1, char *s2);
//_______________________Map________________________//
void check_ext(char *map_path);
void check_new_line(char *full_map, char **line_map);
void init_zeros(int *arr, int size);
void check_map(char *line, int *cep, int index, int *dim);
void valid_map(char **map);
char **read_map(int fd);
char **parse_map(char *map_path, int *length);
//_______________________Init________________________//
void moves_count(t_game *game);
void error(void);
t_game *init_game(int height, int width, char **map);
t_player *init_player(void);
t_enemy *init_enemy(void);
t_anime *init_anime(void *img);
void *init_player_img(t_game *game, char *path);
void set_player(t_game *game, int new_x, int new_y);
void set_map(t_game *game);
void set_wall(t_game *game, char **map, int x, int y);
void set_coll(t_game *game, int x, int y);
//_______________________Anime________________________//
char *get_path_anime(char *path, int index);
t_anime *init_anime(void *img);
void append_anime(t_anime **head, t_anime *anime);
//Enemy
void enemy_anime(t_game *game);
void anime_enemy(t_game *game);
//Player
void anime_player(t_game *game);
void player_anime(t_game *game);
int key_hook(int keycode, t_game *game);
int anime(t_game *game);
void player_move(int keycode, t_game *game);
void enemy_move(t_game *game);
//______________________Move________________________//
void player_move_up(t_game *game);
void player_move_down(t_game *game);
void player_move_right(t_game *game);
void player_move_left(t_game *game);
//______________________set_________________________//
void set_wall(t_game *game, char **map, int x, int y);
void set_ground(t_game *game, int x, int y);
void set_exit(t_game *game, int x, int y);
void *get_image(char *path, t_game *game);
void collision(t_game *game);
void end_game(t_game *game);
int over(t_game *game);
#endif