-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_coordinates.c
More file actions
executable file
·67 lines (62 loc) · 1.54 KB
/
ft_coordinates.c
File metadata and controls
executable file
·67 lines (62 loc) · 1.54 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_coordinates.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aorji <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/16 18:08:08 by aorji #+# #+# */
/* Updated: 2017/12/16 18:08:16 by aorji ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
static void ft_remember_x_y(char *map, int index)
{
int i;
int a;
int b;
int c;
a = 0;
b = 0;
i = 0;
while (a < 4)
{
c = 0;
while (map[i] != '\n')
{
if (map[i] == 35)
{
g_x[index][b] = c;
g_y[index][b++] = a;
}
i++;
c++;
}
i++;
a++;
}
}
void ft_coordinates(char *map, int index)
{
int x_min;
int y_min;
int b;
int c;
b = 0;
c = 0;
ft_remember_x_y(map, index);
y_min = g_y[index][0];
x_min = g_x[index][0];
while (b < 4)
{
if (g_x[index][b] < x_min)
x_min = g_x[index][b];
b++;
}
while (c < 4)
{
g_x[index][c] = g_x[index][c] - x_min;
g_y[index][c] = g_y[index][c] - y_min;
c++;
}
}