aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-19 22:13:50 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-19 22:13:50 +0100
commitcccc0c25b903599c081e3216b4fad1b3c7507b28 (patch)
treecf3292367f16eebe5f1c6cf7445978f095e4eb8f
parentThe og OOP (diff)
download42-cub3d-cccc0c25b903599c081e3216b4fad1b3c7507b28.tar.gz
42-cub3d-cccc0c25b903599c081e3216b4fad1b3c7507b28.tar.bz2
42-cub3d-cccc0c25b903599c081e3216b4fad1b3c7507b28.tar.xz
42-cub3d-cccc0c25b903599c081e3216b4fad1b3c7507b28.tar.zst
42-cub3d-cccc0c25b903599c081e3216b4fad1b3c7507b28.zip
SoundsGoodMan
Diffstat (limited to '')
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h2
-rw-r--r--media/sound/sfx/heal.wavbin179652 -> 179652 bytes
-rw-r--r--src/ft_convert_keycode.c2
-rw-r--r--src/ft_init_lists.c2
-rw-r--r--src/ft_key_events.c7
-rw-r--r--src/ft_switch_weapons.c30
7 files changed, 42 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index d361673..60c2e2d 100644
--- a/Makefile
+++ b/Makefile
@@ -113,6 +113,7 @@ SRCS_NAME += ft_get_weapon_spawn.c
SRCS_NAME += ft_draw_weapons.c
SRCS_NAME += ft_draw_weapons_extra.c
SRCS_NAME += ft_draw_handweap.c
+SRCS_NAME += ft_switch_weapons.c
#--------------------------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
#--------------------------------------------------------------------------------------------------#
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 2affbcd..f4dac89 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -200,5 +200,7 @@ uint32_t ft_darken(t_rgb rgb, t_cub *cl);
void ft_death_screen(t_cub *cl);
void ft_get_fps_count(clock_t delta_time, t_cub *cl);
void ft_find_item(t_player *pl, t_map *ml, t_cub *cl);
+int8_t ft_switch_weap_one(t_cub *cl);
+int8_t ft_switch_weap_two(t_cub *cl);
# endif
diff --git a/media/sound/sfx/heal.wav b/media/sound/sfx/heal.wav
index 395ddcf..3580b84 100644
--- a/media/sound/sfx/heal.wav
+++ b/media/sound/sfx/heal.wav
Binary files differ
diff --git a/src/ft_convert_keycode.c b/src/ft_convert_keycode.c
index a152cfa..22e6169 100644
--- a/src/ft_convert_keycode.c
+++ b/src/ft_convert_keycode.c
@@ -33,5 +33,7 @@ int32_t
keycode = (tmp_code == FT_TAB_KEY) ? (FT_TAB_KEY) : (keycode);
keycode = (tmp_code == FT_RET_KEY) ? (FT_RET_KEY) : (keycode);
keycode = (tmp_code == FT_SPC_KEY) ? (FT_SPC_KEY) : (keycode);
+ keycode = (tmp_code == FT_ONE_KEY) ? (FT_ONE_KEY) : (keycode);
+ keycode = (tmp_code == FT_TWO_KEY) ? (FT_TWO_KEY) : (keycode);
return (keycode);
}
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index dbf4e8f..efb243b 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -32,7 +32,7 @@ t_rgb
** --------------
** -1: no weapon
** 0: weapon one
-** 1: weapon two
+** 2: weapon two
*/
t_player
diff --git a/src/ft_key_events.c b/src/ft_key_events.c
index edacc42..52ef477 100644
--- a/src/ft_key_events.c
+++ b/src/ft_key_events.c
@@ -10,7 +10,6 @@
/* */
/* ************************************************************************** */
-#include <libft.h>
#include <cub3d.h>
#include <stdlib.h>
#include <stdint.h>
@@ -38,6 +37,12 @@ int
return (ft_f1_key(clist));
else if (keycode == FT_SPC_KEY && clist->plist.handles_weapon > -1)
return (ft_space_key(clist));
+ else if (keycode == FT_ONE_KEY && clist->plist.fire == 0
+ && clist->plist.has_weapon[0] == 1 && clist->plist.handles_weapon != 0)
+ return (ft_switch_weap_one(clist));
+ else if (keycode == FT_TWO_KEY && clist->plist.fire == 0
+ && clist->plist.has_weapon[1] == 1 && clist->plist.handles_weapon != 2)
+ return (ft_switch_weap_two(clist));
ft_insert_key(keycode, clist);
return (0);
}
diff --git a/src/ft_switch_weapons.c b/src/ft_switch_weapons.c
new file mode 100644
index 0000000..186f7be
--- /dev/null
+++ b/src/ft_switch_weapons.c
@@ -0,0 +1,30 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_switch_weapons.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:28:55 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:28:55 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <cub3d.h>
+#include <stdint.h>
+
+int8_t
+ ft_switch_weap_one(t_cub *cl)
+{
+ cl->sfx[6].sfx_play(cl->sfx);
+ cl->plist.handles_weapon = 0;
+ return (0);
+}
+
+int8_t
+ ft_switch_weap_two(t_cub *cl)
+{
+ cl->sfx[8].sfx_play(cl->sfx);
+ cl->plist.handles_weapon = 2;
+ return (0);
+}