-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathso_long_check_utils.c
More file actions
86 lines (75 loc) · 2.19 KB
/
so_long_check_utils.c
File metadata and controls
86 lines (75 loc) · 2.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long_check_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: opopov <opopov@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/24 10:41:08 by opopov #+# #+# */
/* Updated: 2025/02/24 17:10:23 by opopov ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
int top_row(t_data *data)
{
int y;
int x;
y = 0;
x = 0;
while (x < data->number_of_tiles_x && data->objects_position[y][x] == '1')
x++;
if (x != data->number_of_tiles_x)
return (1);
return (0);
}
int down_row(t_data *data)
{
int y;
int x;
y = data->number_of_tiles_y - 1;
x = 0;
while (x < data->number_of_tiles_x && data->objects_position[y][x] == '1')
x++;
if (x != data->number_of_tiles_x)
return (1);
return (0);
}
int left_column(t_data *data)
{
int y;
int x;
y = 0;
x = 0;
while (y < data->number_of_tiles_y && data->objects_position[y][x] == '1')
y++;
if (y != data->number_of_tiles_y)
return (1);
return (0);
}
int right_column(t_data *data)
{
int y;
int x;
y = 0;
x = data->number_of_tiles_x - 1;
while (y < data->number_of_tiles_y && data->objects_position[y][x] == '1')
y++;
if (y != data->number_of_tiles_y)
return (1);
return (0);
}
void fill_v(char **map_copy, int y, int x, t_data *data)
{
int rows;
int columns;
rows = data->number_of_tiles_y;
columns = data->number_of_tiles_x;
if (y < 0 || x < 0 || y >= rows || x >= columns
|| map_copy[y][x] == '1' || map_copy[y][x] == 'V')
return ;
map_copy[y][x] = 'V';
fill_v(map_copy, y + 1, x, data);
fill_v(map_copy, y - 1, x, data);
fill_v(map_copy, y, x + 1, data);
fill_v(map_copy, y, x - 1, data);
}