blob: 36e996ae9c5548bd9a51dfcc4e1578c5c9d100f7 (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_damage_bad_boy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: joelecle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:22:32 by joelecle #+# #+# */
/* Updated: 2020/02/14 17:23:42 by joelecle ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <math.h>
static uint8_t
ft_get_bad_boy_id(t_cub *cl)
{
uint8_t i;
i = 0;
while (i < cl->mlist.sprite_nbr[13])
{
if (llround(cl->sprites[13][i].s_pos_x) == (int64_t)cl->rlist.sqx &&
llround(cl->sprites[13][i].s_pos_y) == (int64_t)cl->rlist.sqy)
break ;
i++;
}
return (i);
}
void
ft_damage_bad_boy(t_cub *cl)
{
uint8_t id;
id = ft_get_bad_boy_id(cl);
if (cl->plist.handles_weapon == 0)
cl->bad_boy[id].life -= FT_W_ONE_DANAGE_AMOUNT;
else if (cl->plist.handles_weapon == 2)
cl->bad_boy[id].life -= FT_W_TWO_DANAGE_AMOUNT;
else if (cl->plist.handles_weapon == 4)
cl->bad_boy[id].life -= FT_W_THREE_DANAGE_AMOUNT;
if (cl->bad_boy[id].isdead == 0 &&
cl->bad_boy[id].life <= 0)
{
cl->sfx[13].sfx_play(cl->sfx);
cl->bad_boy[id].isdead = 1;
cl->mlist.map[llround(cl->sprites[13][id].s_pos_y)]
[llround(cl->sprites[13][id].s_pos_x)] = 'x';
}
else if (cl->bad_boy[id].does != 3)
cl->sfx[14].sfx_play(cl->sfx);
}
|