aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_extra_keys.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-23 00:16:36 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-23 00:16:36 +0100
commit3ebd8ba2bd2302327932d877ef8b797793a67542 (patch)
tree0a45b7f6bf98eab0895d71ac85b29413ab707be3 /src/ft_extra_keys.c
parentI think we good (diff)
download42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.tar.gz
42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.tar.bz2
42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.tar.xz
42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.tar.zst
42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.zip
Cool
Diffstat (limited to '')
-rw-r--r--src/ft_extra_keys.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ft_extra_keys.c b/src/ft_extra_keys.c
index a78f821..097e2e2 100644
--- a/src/ft_extra_keys.c
+++ b/src/ft_extra_keys.c
@@ -71,8 +71,15 @@ 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;
}