-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathso_long.c
107 lines (100 loc) · 2.72 KB
/
so_long.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbourziq <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/12 21:59:15 by sbourziq #+# #+# */
/* Updated: 2024/03/12 21:59:26 by sbourziq ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void ft_print_map(t_mlx *data)
{
ft_printf("your map is not correct\n");
ft_free(data);
exit(1);
}
int run(t_mlx *data)
{
mlx_clear_window(data->mlx, data->mlx_win);
(data->speed)++;
if (data->speed == 15)
{
data->speed = 0;
loaction_enemy(data);
ft_enemy_speed(data, data->i, data->j, data->x);
}
data->x = 0;
data->i = 0;
data->j = 0;
(data->count)++;
if (data->count == 10 * 7)
data->count = 0;
if (ft_check_c(data) == 1)
(data->count_door)++;
ft_open_img(data);
return (1);
}
void ft_all_var(int *i, int *height, t_mlx *data)
{
*height = 1;
*i = 1;
data->count = 0;
data->count_door = 0;
data->count_plyer = 0;
data->count_enemy = 0;
data->x = 0;
data->i = 0;
data->j = 0;
data->speed = 0;
data->count_enemy_left = 0;
}
void ft_handl_map(int *height, t_mlx *data, char **argv, t_node **witdh)
{
ft_path_map(argv);
ft_count_line(height, witdh, argv);
ft_sam_number(*witdh);
data->str = (char **)malloc(*height * sizeof(char *) + 1);
if (data->str == NULL)
return ;
data->height = *height;
data->width = (*witdh)->data;
ft_str_map(data->str, argv);
ft_check_last_wall(&data->str[(*height) - 2]);
if (ft_check_map(data->str, data) == 1)
ft_print_map(data);
ft_free(data);
ft_str_map(data->str, argv);
if (ft_check_map2(data->str, data) == 1)
ft_print_map(data);
ft_free(data);
ft_str_map(data->str, argv);
if (ft_check_map3(data->str, data) == 1)
ft_print_map(data);
ft_free(data);
ft_str_map(data->str, argv);
}
int main(int argc, char **argv)
{
int height;
int i;
t_node *witdh;
t_mlx data;
ft_all_var(&i, &height, &data);
if (argc == 1)
{
ft_printf("we need map\n");
return (0);
}
else if (argc == 2)
{
ft_handl_map(&height, &data, argv, &witdh);
ft_minilbx(&data, witdh, height);
system("leaks a.out");
}
else
ft_printf("you have a lot of argimont\n");
return (0);
}