-
Notifications
You must be signed in to change notification settings - Fork 0
/
is_closed.c
61 lines (56 loc) · 1.72 KB
/
is_closed.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* is_closed.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rvan-der <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/11 19:38:09 by rvan-der #+# #+# */
/* Updated: 2017/02/11 21:03:44 by rvan-der ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
int is_closed2(t_plateau p, t_ennemi e)
{
int x;
int y;
x = (e.sqr).e + 1;
while (--x > (e.sqr).w - 1)
{
y = (p.size).y;
while (--y > -1 && (p.map)[y][x] != p.pl)
if (is_ennemi((p.map)[y][x], p.pl))
return (0);
}
y = (e.sqr).s + 1;
while (--y > (e.sqr).n - 1)
{
x = -1;
while (++x < (p.size).x && (p.map)[y][x] != p.pl)
if (is_ennemi((p.map)[y][x], p.pl))
return (0);
}
return (1);
}
int is_closed(t_plateau p, t_ennemi e)
{
int x;
int y;
x = (e.sqr).w - 1;
while (++x < (e.sqr).e + 1)
{
y = -1;
while (++y < (p.size).y && (p.map)[y][x] != p.pl)
if (is_ennemi((p.map)[y][x], p.pl))
return (0);
}
y = (e.sqr).n - 1;
while (++y < (e.sqr).s + 1)
{
x = (p.size).x;
while (--x > -1 && (p.map)[y][x] != pl)
if (is_ennemi((p.map)[y][x], p.pl))
return (0);
}
return (is_closed2(p));
}