-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverifpos.c
111 lines (104 loc) · 2.78 KB
/
verifpos.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
** EPITECH PROJECT, 2024
** Untitled (Workspace)
** File description:
** verifpos
*/
#include "include/my.h"
#include "include/my_p.h"
static void verifpos_pas_aux(elem_t elem, int x, int y)
{
if (x >= 80 && y >= 45 && x <= 110 && y <= 75) {
draw_pas(elem, 80, 45);
}
if (x >= 10 && y >= 80 && x <= 40 && y <= 110) {
draw_pas(elem, 10, 80);
}
if (x >= 45 && y >= 80 && x <= 75 && y <= 110) {
draw_pas(elem, 45, 80);
}
if (x >= 80 && y >= 80 && x <= 110 && y <= 110) {
draw_pas(elem, 80, 80);
}
if (x >= 115 && y >= 45 && x <= 145 && y <= 75) {
draw_pas(elem, 115, 45);
}
if (x >= 45 && y >= 45 && x <= 75 && y <= 75) {
draw_pas(elem, 45, 45);
}
}
void verifpos_pas(elem_t elem, int x, int y)
{
sfRenderWindow_clear(elem.window, sfWhite);
if (x >= 10 && y >= 45 && x <= 40 && y <= 75) {
draw_pas(elem, 10, 45);
}
verifpos_pas_aux(elem, x, y);
draw_pack(elem);
sfRenderWindow_display(elem.window);
}
static elem_t verifpos_aux2(elem_t elem, int x, int y)
{
if (x >= 80 && y >= 80 && x <= 110 && y <= 110
&& sfMouse_isButtonPressed(sfMouseLeft)) {
draw_cli(elem, 80, 80);
elem.colo = sfBlack;
elem.temp = 1;
}
if (x >= 115 && y >= 45 && x <= 145 && y <= 75
&& sfMouse_isButtonPressed(sfMouseLeft)) {
draw_cli(elem, 115, 45);
elem.colo = sfCyan;
elem.temp = 1;
}
if (x >= 45 && y >= 45 && x <= 75 && y <= 75
&& sfMouse_isButtonPressed(sfMouseLeft)) {
draw_cli(elem, 45, 45);
elem.colo = sfGreen;
elem.temp = 1;
}
return elem;
}
static elem_t verifpos_aux(elem_t elem, int x, int y)
{
if (x >= 80 && y >= 45 && x <= 110 && y <= 75
&& sfMouse_isButtonPressed(sfMouseLeft)) {
draw_cli(elem, 80, 45);
elem.colo = sfBlue;
elem.temp = 1;
}
if (x >= 10 && y >= 80 && x <= 40 && y <= 110
&& sfMouse_isButtonPressed(sfMouseLeft)) {
draw_cli(elem, 10, 80);
elem.colo = sfMagenta;
elem.temp = 1;
}
if (x >= 45 && y >= 80 && x <= 75 && y <= 110
&& sfMouse_isButtonPressed(sfMouseLeft)) {
draw_cli(elem, 45, 80);
elem.colo = sfYellow;
elem.temp = 1;
}
elem = verifpos_aux2(elem, x, y);
return elem;
}
elem_t verifpos(elem_t elem)
{
sfVector2i mouse;
int x;
int y;
elem.temp = 0;
while (elem.temp == 0) {
mouse = sfMouse_getPositionRenderWindow(elem.window);
x = mouse.x;
y = mouse.y;
if (x >= 10 && y >= 45 && x <= 40 && y <= 75
&& sfMouse_isButtonPressed(sfMouseLeft)) {
draw_cli(elem, 10, 45);
elem.colo = sfRed;
elem.temp = 1;
}
elem = verifpos_aux(elem, x, y);
}
return elem;
}