aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d.h1
-rw-r--r--inc/cub3d_defines.h2
-rw-r--r--src/ft_convert_keycode.c1
-rw-r--r--src/ft_find_item.c5
-rw-r--r--src/ft_key_events.c3
-rw-r--r--src/ft_switch_weapons.c8
-rw-r--r--src/ft_tex_weap_init.c2
7 files changed, 20 insertions, 2 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index ceee453..b9e0667 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -218,5 +218,6 @@ 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);
+int8_t ft_switch_weap_three(t_cub *cl);
# endif
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index 1e71801..ca0cead 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -72,6 +72,7 @@ enum
# define FT_SPC_KEY 49
# define FT_ONE_KEY 18
# define FT_TWO_KEY 19
+# define FT_THREE_KEY 20
# else
# define FT_W_KEY 119
# define FT_A_KEY 97
@@ -86,6 +87,7 @@ enum
# define FT_SPC_KEY 32
# define FT_ONE_KEY 49
# define FT_TWO_KEY 50
+# define FT_THREE_KEY 51
# endif
/*
diff --git a/src/ft_convert_keycode.c b/src/ft_convert_keycode.c
index 22e6169..01d315c 100644
--- a/src/ft_convert_keycode.c
+++ b/src/ft_convert_keycode.c
@@ -35,5 +35,6 @@ int32_t
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);
+ keycode = (tmp_code == FT_THREE_KEY) ? (FT_THREE_KEY) : (keycode);
return (keycode);
}
diff --git a/src/ft_find_item.c b/src/ft_find_item.c
index c95fa0a..caeb3f4 100644
--- a/src/ft_find_item.c
+++ b/src/ft_find_item.c
@@ -45,8 +45,9 @@ static void
cl->weaps[weap_id][0].s_pos_x = 0;
cl->weaps[weap_id][0].s_pos_y = 0;
pl->has_weapon[weap_id] = 1;
- pl->handles_weapon = (weap_id == 1) ? (2) : (weap_id);
- pl->handles_weapon = (weap_id == 2) ? (4) : (weap_id);
+ pl->handles_weapon = (weap_id == 0) ? (0) : (pl->handles_weapon);
+ pl->handles_weapon = (weap_id == 1) ? (2) : (pl->handles_weapon);
+ pl->handles_weapon = (weap_id == 2) ? (4) : (pl->handles_weapon);
if (weap_id == 0)
cl->sfx[6].sfx_play(cl->sfx);
else if (weap_id == 1)
diff --git a/src/ft_key_events.c b/src/ft_key_events.c
index 52ef477..8ea5b90 100644
--- a/src/ft_key_events.c
+++ b/src/ft_key_events.c
@@ -43,6 +43,9 @@ int
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));
+ else if (keycode == FT_THREE_KEY && clist->plist.fire == 0
+ && clist->plist.has_weapon[2] == 1 && clist->plist.handles_weapon != 4)
+ return (ft_switch_weap_three(clist));
ft_insert_key(keycode, clist);
return (0);
}
diff --git a/src/ft_switch_weapons.c b/src/ft_switch_weapons.c
index 186f7be..c936ed6 100644
--- a/src/ft_switch_weapons.c
+++ b/src/ft_switch_weapons.c
@@ -28,3 +28,11 @@ int8_t
cl->plist.handles_weapon = 2;
return (0);
}
+
+int8_t
+ ft_switch_weap_three(t_cub *cl)
+{
+ cl->sfx[10].sfx_play(cl->sfx);
+ cl->plist.handles_weapon = 4;
+ return (0);
+}
diff --git a/src/ft_tex_weap_init.c b/src/ft_tex_weap_init.c
index ab8ed53..3425fb4 100644
--- a/src/ft_tex_weap_init.c
+++ b/src/ft_tex_weap_init.c
@@ -20,6 +20,8 @@
** 1: weapon one fire
** 2: weapon two
** 3: weapon two fire
+** 4: weapon three
+** 5: weapon three fire
*/
void