-
Notifications
You must be signed in to change notification settings - Fork 0
/
fillit_utils2.c
57 lines (51 loc) · 1.66 KB
/
fillit_utils2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fillit_utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: etexier <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/26 17:31:02 by etexier #+# #+# */
/* Updated: 2019/11/28 15:45:16 by etexier ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
unsigned short int move_to_top(unsigned short int tetrino)
{
int count;
count = 0;
while (count < 3)
{
if ((tetrino & 0xF000) == 0)
tetrino = tetrino << 4;
count++;
}
count = 0;
while (count < 3)
{
if (is_on(tetrino, 0) == 0 && is_on(tetrino, 4) == 0 &&
is_on(tetrino, 8) == 0 && is_on(tetrino, 12) == 0)
tetrino = shift_left(tetrino);
count++;
}
return (tetrino);
}
void set_coord(t_tetrino *t, int row, int col)
{
t->coord[ROW] = row;
t->coord[COL] = col;
}
void init_coord(t_tetrino *t)
{
set_coord(t, 0, 0);
}
unsigned short int make_tetrino(char *row1,
char *row2,
char *row3,
char *row4)
{
return (add_tetrino_line(
add_tetrino_line(
add_tetrino_line(
add_tetrino_line(0, row1), row2), row3), row4));
}