aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)