aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_key_events.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-17 20:24:57 +0100
committerRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-17 20:24:57 +0100
commitbe34d7c8b2565ac055f9dc77111a1029ebd87d77 (patch)
tree750ceb2402800c855c04c3e66a7294f11c09a7b1 /src/ft_key_events.c
parentMulti-key in progress (diff)
download42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.tar.gz
42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.tar.bz2
42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.tar.xz
42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.tar.zst
42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.zip
sex
Diffstat (limited to '')
-rw-r--r--src/ft_key_events.c39
1 files changed, 2 insertions, 37 deletions
diff --git a/src/ft_key_events.c b/src/ft_key_events.c
index 54f3033..317715d 100644
--- a/src/ft_key_events.c
+++ b/src/ft_key_events.c
@@ -26,51 +26,16 @@ static void
clist->key_input[i] = keycode;
}
-static void
- ft_collision(float old_y, float old_x, t_player *pl, t_map *ml)
-{
- const size_t x = pl->pos_x;
- const size_t y = pl->pos_y;
-
- if (ml->map[y][x] == '1')
- {
- pl->pos_y = old_y;
- pl->pos_x = old_x;
- }
-}
-
int
ft_key_event(int keycode, t_cub *clist)
{
- int (*fun_ptr[6])(t_cub*);
const int32_t tmp_code = keycode;
- const float old_y = clist->plist->pos_y;
- const float old_x = clist->plist->pos_x;
- fun_ptr[0] = ft_w_key;
- fun_ptr[1] = ft_a_key;
- fun_ptr[2] = ft_s_key;
- fun_ptr[3] = ft_d_key;
- fun_ptr[4] = ft_left_key;
- fun_ptr[5] = ft_right_key;
keycode = ft_convert_keycode(tmp_code);
- ft_insert_key(keycode, clist);
- ft_printf("keys [%d][%d][%d][%d][%d]\n",
- clist->key_input[0],
- clist->key_input[1],
- clist->key_input[2],
- clist->key_input[3],
- clist->key_input[4]);
- if (keycode <= 5)
- {
- (*fun_ptr[keycode])(clist);
- ft_collision(old_y, old_x, clist->plist, clist->mlist);
- ft_draw_scene(clist);
- return (0);
- }
- else if (keycode == FT_ESC_KEY)
+ if (keycode == FT_ESC_KEY)
return (ft_exit(0, (clist)));
else if (keycode == FT_F1_KEY || keycode == FT_TAB_KEY)
return (ft_f1_key(clist));
+ ft_insert_key(keycode, clist);
return (0);
}