aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_extra_keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_extra_keys.c')
-rw-r--r--src/ft_extra_keys.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ft_extra_keys.c b/src/ft_extra_keys.c
index f5a501a..f8a6db8 100644
--- a/src/ft_extra_keys.c
+++ b/src/ft_extra_keys.c
@@ -73,11 +73,21 @@ int
int
ft_space_key(t_cub *clist)
{
- if (clist->plist.fire == 0)
+ uint8_t w_id;
+
+ w_id = clist->plist.handles_weapon;
+ w_id = (w_id == 2) ? (1) : (w_id);
+ w_id = (w_id == 4) ? (2) : (w_id);
+ if (clist->plist.fire == 0 &&
+ (clist->plist.ammo[w_id] > 0 || clist->plist.ammo[w_id] == -4))
{
+ clist->plist.ammo[w_id] -= w_id;
clist->sfx[clist->plist.handles_weapon + 7].sfx_play(clist->sfx);
clist->plist.fire = 1;
ft_shoot(clist, clist->wlist.x_size / 2);
+ return (0);
}
+ else if (clist->plist.fire == 0 && clist->plist.ammo[w_id] <= 0)
+ clist->sfx[12].sfx_play(clist->sfx);
return (0);
}