-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolve_iter2.c
53 lines (47 loc) · 1.61 KB
/
resolve_iter2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* resolve_iter2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: etexier <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/06 09:59:07 by etexier #+# #+# */
/* Updated: 2020/01/06 09:59:19 by etexier ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
int update_coord_iter(t_grid *grid, t_tetrino *t)
{
if ((t->coord[COL] = (t->coord[COL]+1) % grid->csize))
return (1);
t->coord[ROW] = (t->coord[ROW] + 1) % grid->csize;
return (t->coord[ROW]);
}
int ins_tx_iter(t_grid *grid, int row, int col, t_tetrino *t)
{
int count;
count = 0;
t->coord[COL] = col;
t->coord[ROW] = row;
while (count < 4)
{
grid->table[row + t->crd4[count][0]][col + t->crd4[count][1]] = t->marker;
count++;
}
return (1);
}
int remove_tetrino_iter(t_grid *grid, t_tetrino *t)
{
int count;
int col;
int row;
count = 0;
col = t->coord[COL];
row = t->coord[ROW];
while (count < 4)
{
grid->table[row + t->crd4[count][0]][col + t->crd4[count][1]] = EMPTY;
count++;
}
return (1);
}