forked from nicolas-flasque-efrei/MARC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loc.c
52 lines (44 loc) · 884 Bytes
/
loc.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
//
// Created by flasque on 19/10/2024.
//
#include "loc.h"
t_localisation loc_init(int x, int y, t_orientation ori)
{
t_localisation loc;
loc.pos.x = x;
loc.pos.y = y;
loc.ori = ori;
return loc;
}
int isValidLocalisation(t_position loc, int x_max, int y_max)
{
return (loc.x >= 0 && loc.x < x_max && loc.y >= 0 && loc.y < y_max);
}
t_position LEFT(t_position pos)
{
t_position new_pos;
new_pos.x = pos.x - 1;
new_pos.y = pos.y;
return new_pos;
}
t_position RIGHT(t_position pos)
{
t_position new_pos;
new_pos.x = pos.x + 1;
new_pos.y = pos.y;
return new_pos;
}
t_position UP(t_position pos)
{
t_position new_pos;
new_pos.x = pos.x;
new_pos.y = pos.y - 1;
return new_pos;
}
t_position DOWN(t_position pos)
{
t_position new_pos;
new_pos.x = pos.x;
new_pos.y = pos.y + 1;
return new_pos;
}