-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathso_long.h
More file actions
122 lines (104 loc) · 2.95 KB
/
so_long.h
File metadata and controls
122 lines (104 loc) · 2.95 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sfelici <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/21 15:25:44 by sfelici #+# #+# */
/* Updated: 2025/02/21 15:26:30 by sfelici ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SO_LONG_H
# define SO_LONG_H
# include "libraries/minilibx-linux/mlx.h"
# include "libraries/libft/libft.h"
# include <fcntl.h>
# include <unistd.h>
# include <stdlib.h>
# include <stdio.h>
# define GRID_SIZE 64
# define MAX_ENEMIES 16
typedef struct s_point
{
int x;
int y;
} t_point;
typedef struct s_enemy
{
int x;
int y;
int dir_x;
int dir_y;
} t_enemy;
typedef struct s_textures
{
void *wall_img;
void *exit_img_closed;
void *exit_img_open;
void *collectible_img;
void *player_img;
void *floor_img;
void *enemy_img;
void *explosion_img;
void *flint_img;
} t_textures;
typedef struct s_map_info
{
int rows;
int cols;
int player_count;
int exit_count;
int collectible_count;
int player_x;
int player_y;
} t_map_info;
typedef struct s_dfs_info
{
char **map;
t_map_info *info;
int *collectibles_found;
int *exit_found;
} t_dfs_info;
typedef struct s_vars
{
void *mlx;
void *win;
char **map;
int move_count;
t_map_info map_info;
t_textures textures;
t_point player_pos;
t_enemy enemies[MAX_ENEMIES];
int enemy_count;
} t_vars;
int ft_printf(const char *format, ...);
// PARSER
char **read_map(const char *file_path);
int check_map_errors(char **map, t_map_info *info);
int check_path(char **map, t_map_info *info);
int is_move_valid(t_vars *vars, int new_x, int new_y);
// DRAWERS
void draw_map(t_vars *vars);
void draw_floor(t_vars *vars, int x, int y);
void draw_wall(t_vars *vars, int x, int y);
void draw_collectible(t_vars *vars, int x, int y);
void draw_exit(t_vars *vars, int x, int y);
void draw_player(t_vars *vars, int x, int y);
void draw_enemy(t_vars *vars, int x, int y);
void draw_flint(t_vars *vars, int x, int y);
// CLEANUP
void ft_cleanup(t_vars *vars);
void free_map(char **map);
void ft_cleanup_textures(t_vars *vars);
// MOVEMENT
int key_press(int keycode, t_vars *vars);
void process_tile(t_vars *vars, int new_x, int new_y);
void move_enemies(t_vars *vars);
// UTILS
void game_over(t_vars *vars);
// ENEMY
void init_enemies(t_vars *vars);
void handle_kill(t_vars *vars);
void kill_enemy(t_vars *vars, int x, int y);
#endif