-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoordination.c
78 lines (71 loc) · 1.77 KB
/
coordination.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* coordination.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yelee <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/25 14:38:19 by yelee #+# #+# */
/* Updated: 2020/02/25 14:38:34 by yelee ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
void ft_recoordi(t_tetris **head)
{
t_tetris *temp;
int i;
int j;
int k;
temp = *head;
k = -1;
while (temp->next)
{
i = -1;
j = 0;
while (++i < SIZE)
if (temp->tet[i] == '#')
while (j < 8)
{
temp->coord[j] = temp->coord[j] - (i % 5);
temp->coord[j + 1] = temp->coord[j + 1] - (i / 5);
j += 2;
}
temp->tet[0] = ++k + 'A';
temp = ft_updatetet(temp)->next;
}
}
int ft_smallest_size(int size)
{
int total_blocks;
int i;
total_blocks = size * 4;
i = 0;
while (i * i < total_blocks)
i++;
return (i);
}
void ft_coordination(t_tetris **head)
{
t_tetris *temp;
int i;
int j;
temp = *head;
while (temp->next)
{
i = 0;
j = 0;
while (i < SIZE)
{
if (temp->tet[i] == '#')
{
temp->coord[j] = i % 5;
j++;
temp->coord[j] = i / 5;
j++;
}
i++;
}
temp = temp->next;
}
ft_recoordi(head);
}