From 3831ffb031bd236cba9eedd2b6dc24a6d9bff515 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 14 Feb 2020 00:04:37 +0100 Subject: Added turn around keys --- src/ft_key_events.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/ft_key_events.c') diff --git a/src/ft_key_events.c b/src/ft_key_events.c index da416fa..2c189ad 100644 --- a/src/ft_key_events.c +++ b/src/ft_key_events.c @@ -61,23 +61,28 @@ int { t_player *pl; t_map *ml; - int8_t (*fun_ptr[4])(t_cub*); + int8_t (*fun_ptr[6])(t_cub*); const uint16_t tmp_code = keycode; 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; ft_printf("Key [%d] pressed\n", tmp_code); (tmp_code == FT_W_KEY) ? (keycode = 0) : 0; (tmp_code == FT_A_KEY) ? (keycode = 1) : 0; (tmp_code == FT_S_KEY) ? (keycode = 2) : 0; (tmp_code == FT_D_KEY) ? (keycode = 3) : 0; - (tmp_code == 3) ? (keycode = INT16_MAX) : 0; - (tmp_code == 4) ? (keycode = INT16_MAX) : 0; + (tmp_code == FT_L_ARR_KEY) ? (keycode = 4) : 0; + (tmp_code == FT_R_ARR_KEY) ? (keycode = 5) : 0; + (tmp_code == 3) ? (keycode = UINT16_MAX) : 0; + (tmp_code == 4) ? (keycode = UINT16_MAX) : 0; + (tmp_code == 5) ? (keycode = UINT16_MAX) : 0; pl = clist->plist; ml = clist->mlist; - if (keycode <= 3) + if (keycode <= 5) { (*fun_ptr[keycode])(clist); (pl->pos_y < 1) ? (pl->pos_y = 1.1) : 0; -- cgit v1.2.3