-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_click.c
108 lines (101 loc) · 3.01 KB
/
event_click.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
/*
** EPITECH PROJECT, 2018
** event
** File description:
** defender game event
*/
#include "include/my.h"
int price(int i)
{
if (i == 1)
return (100);
if (i == 2)
return (200);
if (i == 3)
return (400);
if (i == 4)
return (800);
return (100);
}
int menu_event_click(sfEvent event, int i, int stat)
{
if (event.type == sfEvtMouseButtonReleased) {
if (i == 1)
stat = 4;
if (i == 2)
stat = 1;
if (i == 3) {
sfSleep((sfTime){200000});
stat = 84;
}
}
return (stat);
}
int choice_event_click(game_t *game, sfEvent event, int i, int stat)
{
if (event.type == sfEvtMouseButtonReleased) {
if (i == 0) {
stat = 2;
game_set(game, "map1.txt");
sfSleep((sfTime){200000});
}
if (i == 1) {
stat = 2;
game_set(game, "map2.txt");
sfSleep((sfTime){200000});
}
if (i == 2) {
stat = 2;
game_set(game, "map3.txt");
sfSleep((sfTime){200000});
}
}
return (stat);
}
int pause_event_click(game_t *game, sfEvent event, int i, int stat)
{
if (event.type == sfEvtMouseButtonReleased) {
if (i == 0) {
stat = 2;
sfClock_restart(game->clock[0]);
sfClock_restart(game->clock[1]);
sfClock_restart(game->clock[2]);
sfClock_restart(game->clock[3]);
sfClock_restart(game->clock[4]);
sfSleep((sfTime){200000});
}
if (i == 1) {
sfSleep((sfTime){200000});
stat = 0;
}
if (i == 2) {
sfSleep((sfTime){200000});
stat = 84;
}
}
return (stat);
}
void turret_event_click(game_t *game, sfEvent event, int i)
{
int a = price(i);
if (event.type == sfEvtMouseButtonPressed && game->game_stat->coins >= a
&& game->game_stat->tnb < TR) {
game->game_stat->cost = a;
game->game_turret->turret_rect[game->game_stat->tnb + 6] =
((sfFloatRect){100, ((i - 1) * 400), 400, 400});
game->game_turret->turret_rect[game->game_stat->tnb + 26] =
((sfFloatRect){500, ((i - 1) * 500), 500, 500});
sfSprite_setTextureRect(game->game_turret->turret_sprite
[game->game_stat->tnb + 6], (sfIntRect){(game->game_turret->turret_rect
[game->game_stat->tnb + 6]).top, (game->game_turret->turret_rect
[game->game_stat->tnb + 6]).left, (game->game_turret->turret_rect
[game->game_stat->tnb + 6]).height, (game->game_turret->turret_rect
[game->game_stat->tnb + 6]).width});
game->game_stat->type[game->game_stat->tnb] = i;
sfSprite_setColor(game->game_turret->turret_sprite
[game->game_stat->tnb + 6], sfColor_fromRGBA (255, 255, 255, 150));
sfCircleShape_setOutlineColor(game->game_turret->turret_circle
[game->game_stat->tnb], sfColor_fromRGBA(207, 58, 26, 200));
game->game_stat->dstat = 1;
}
}