-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_utils2.c
More file actions
86 lines (77 loc) · 1.81 KB
/
main_utils2.c
File metadata and controls
86 lines (77 loc) · 1.81 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main_utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aylaaouf <aylaaouf@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/11 08:40:59 by aylaaouf #+# #+# */
/* Updated: 2025/03/20 07:05:37 by aylaaouf ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
int runer(t_game *game)
{
static int frame;
if (find_enemy_before(game))
enemy_patrol(game);
frame++;
if (frame == 100)
{
draw_map(game);
frame = 0;
}
return (0);
}
int close_window(t_game *game)
{
free_map(game->map);
clean_game(game);
exit(0);
return (0);
}
int no_collectible_more(t_game *game)
{
int i;
int j;
i = 0;
while (i < game->map->height)
{
j = 0;
while (j < game->map->width)
{
if (game->map->map[i][j] == 'C')
return (0);
j++;
}
i++;
}
return (1);
}
int is_rectangular(t_map *map)
{
int i;
int j;
if (!map || !map->map || !map->map[0])
return (0);
i = 0;
while (map->map[i])
{
j = i + 1;
while (map->map[j])
{
if (ft_strlen(map->map[i]) != ft_strlen(map->map[j]))
return (0);
j++;
}
i++;
}
return (1);
}
void helper_valid_path(t_game *game)
{
ft_printf("Error: Map is not accessible.\n");
free_map(game->map);
clean_game(game);
exit(0);
}