-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_square.c
56 lines (52 loc) · 1.83 KB
/
create_square.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* create_square.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yabdulha <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/09 16:13:31 by yabdulha #+# #+# */
/* Updated: 2018/11/14 20:58:52 by yabdulha ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
/*
** Create a square surrounding the enemy player. Start from top left and create
** points towards the bottom right.
*/
void create_square(t_filler *data)
{
t_co *start;
start = (t_co*)malloc(sizeof(*start));
start->x = data->le;
start->y = data->up;
add_co(start->x, start->y, &data->square, 0);
while (start->y < data->lo)
{
if (map(data, start->x, start->y) == '.')
add_co(start->x, start->y, &data->square, 0);
start->y++;
}
start->x = data->le;
while (start->x <= data->ri)
{
if (map(data, start->x, start->y) == '.')
add_co(start->x, start->y, &data->square, 0);
start->x++;
}
start->x = data->le;
start->y = data->up;
while (start->x < data->ri)
{
if (map(data, start->x, start->y) == '.')
add_co(start->x, start->y, &data->square, 0);
start->x++;
}
start->y = data->up;
while (start->y <= data->lo)
{
if (map(data, start->x, start->y) == '.')
add_co(start->x, start->y, &data->square, 0);
start->y++;
}
}