aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-14 17:50:48 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-14 17:50:48 +0200
commit28abf9e55ba276fbaa869228c9dccdcdaef33236 (patch)
treed2b2bf8d8993ca46a60187d4bb446a3e050d1dfd /src
parentDoing norminette (diff)
download42-cub3d-28abf9e55ba276fbaa869228c9dccdcdaef33236.tar.gz
42-cub3d-28abf9e55ba276fbaa869228c9dccdcdaef33236.tar.bz2
42-cub3d-28abf9e55ba276fbaa869228c9dccdcdaef33236.tar.xz
42-cub3d-28abf9e55ba276fbaa869228c9dccdcdaef33236.tar.zst
42-cub3d-28abf9e55ba276fbaa869228c9dccdcdaef33236.zip
Normed this
Diffstat (limited to 'src')
-rw-r--r--src/ft_extra_keys.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/ft_extra_keys.c b/src/ft_extra_keys.c
index e4d0853..47c3535 100644
--- a/src/ft_extra_keys.c
+++ b/src/ft_extra_keys.c
@@ -69,11 +69,25 @@ int
return (0);
}
+static void
+ ft_choose_colt_sound(t_cub *clist)
+{
+ static uint8_t ref = 0;
+
+ if (ref % 3 == 0)
+ clist->sfx[9].sfx_play(clist->sfx);
+ else if (ref % 3 == 2)
+ clist->sfx[16].sfx_play(clist->sfx);
+ else if (ref % 3 == 1)
+ clist->sfx[17].sfx_play(clist->sfx);
+ ref += 2;
+ ref = (ref > 200) ? (0) : (ref);
+}
+
int
ft_space_key(t_cub *clist)
{
uint8_t w_id;
- static uint8_t ref = 0;
w_id = clist->plist.handles_weapon;
w_id = (w_id == 2) ? (1) : (w_id);
@@ -85,18 +99,9 @@ int
if (clist->plist.handles_weapon != 2)
clist->sfx[clist->plist.handles_weapon + 7].sfx_play(clist->sfx);
else
- {
- if (ref % 3 == 0)
- clist->sfx[9].sfx_play(clist->sfx);
- else if (ref % 3 == 2)
- clist->sfx[16].sfx_play(clist->sfx);
- else if (ref % 3 == 1)
- clist->sfx[17].sfx_play(clist->sfx);
- ref += 2;
- ref = (ref > 200) ? (0) : (ref);
- }
+ ft_choose_colt_sound(clist);
clist->plist.fire = 1;
- ft_shoot(clist);
+ ft_shoot(clist);
return (0);
}
else if (clist->plist.fire == 0 && clist->plist.ammo[w_id] <= 0)