-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_cursor.c
96 lines (89 loc) · 2.64 KB
/
set_cursor.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
/*
** EPITECH PROJECT, 2019
** my_rpg
** File description:
** cursor
*/
#include "my.h"
static void click_buttons(sfMouseButtonEvent mouse, \
game_t *g, sfRenderWindow *window)
{
if (mouse.x >= 460 && mouse.x <= 740 && \
mouse.y >= 360 && mouse.y <= 480)
g->state = 1;
if (mouse.x >= 460 && mouse.x <= 740 && \
mouse.y >= 510 && mouse.y <= 630)
g->state = 2;
if (mouse.x >= 460 && mouse.x <= 740 && \
mouse.y >= 810 && mouse.y <= 930)
sfRenderWindow_close(window);
}
static void click_buttons_2(sfMouseButtonEvent mouse, \
game_t *g)
{
if (g->state == -1) {
if (mouse.x >= 950 && mouse.x <= 1175 && \
mouse.y >= 5 && mouse.y <= 110)
g->state = -2;
}
if (g->state == 0) {
if (mouse.x >= 460 && mouse.x <= 740 && \
mouse.y >= 660 && mouse.y <= 780)
g->state = 6;
}
}
static void change_player_2(sfMouseButtonEvent mouse, \
game_t *g)
{
if (mouse.x >= 75 && mouse.x <= 225 && \
mouse.y >= 250 && mouse.y <= 400) {
g->ps->check = 1;
g->ps->rect.left = 0;
sfRectangleShape_setPosition(g->ps->r, set_position(75, 250));
sfSound_play(g->s->emanuel);
}
if (mouse.x >= 375 && mouse.x <= 525 && \
mouse.y >= 250 && mouse.y <= 400) {
g->ps->check = 2;
g->ps->rect.left = 200;
sfRectangleShape_setPosition(g->ps->r, set_position(375, 250));
sfSound_play(g->s->donjeta);
}
sfSprite_setTextureRect(g->ps->names, g->ps->rect);
}
static void change_player(sfMouseButtonEvent mouse, \
game_t *g)
{
if (mouse.x >= 675 && mouse.x <= 825 && \
mouse.y >= 250 && mouse.y <= 400) {
g->ps->check = 3;
g->ps->rect.left = 400;
sfRectangleShape_setPosition(g->ps->r, set_position(675, 250));
sfSound_play(g->s->endri);
}
if (mouse.x >= 975 && mouse.x <= 1125 && \
mouse.y >= 250 && mouse.y <= 400) {
g->ps->check = 4;
g->ps->rect.left = 600;
sfRectangleShape_setPosition(g->ps->r, set_position(975, 250));
sfSound_play(g->s->besart);
}
sfSprite_setTextureRect(g->ps->names, g->ps->rect);
}
void change_state(game_t *g, sfEvent event, \
sfRenderWindow *window)
{
sfMouseButtonEvent mouse = event.mouseButton;
if (event.type == sfEvtMouseButtonReleased) {
if (g->state == -1 || g->state == 0)
click_buttons_2(mouse, g);
if (g->state == 0)
click_buttons(mouse, g, window);
if (g->state == -2) {
change_player(mouse, g);
change_player_2(mouse, g);
player_changed(g);
}
}
change_state_3(g, event, window);
}