diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-02-21 20:39:35 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-02-21 20:39:35 +0100 |
commit | 9aab05aa368be99c2f5eec40ea7ae06843b2171b (patch) | |
tree | 3379cd86b953d04074a25f88b6461074ccbc80ab | |
parent | Removed shit music (diff) | |
download | 42-cub3d-9aab05aa368be99c2f5eec40ea7ae06843b2171b.tar.gz 42-cub3d-9aab05aa368be99c2f5eec40ea7ae06843b2171b.tar.bz2 42-cub3d-9aab05aa368be99c2f5eec40ea7ae06843b2171b.tar.xz 42-cub3d-9aab05aa368be99c2f5eec40ea7ae06843b2171b.tar.zst 42-cub3d-9aab05aa368be99c2f5eec40ea7ae06843b2171b.zip |
basically C++
-rw-r--r-- | inc/cub3d_structs.h | 1 | ||||
-rw-r--r-- | src/ft_init_lists.c | 13 | ||||
-rw-r--r-- | src/ft_key_loop.c | 17 |
3 files changed, 18 insertions, 13 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index f5c295c..823a21b 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -117,6 +117,7 @@ typedef struct s_cub uint8_t minimap; char errmsg[40]; int32_t key_input[5]; + int (*key_ptr[6])(struct s_cub*); struct s_win *wlist; struct s_player *plist; struct s_map *mlist; diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index 6917db2..0fa4ba2 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -78,16 +78,19 @@ static t_cub !(clist->mlist = ft_init_map())) return (NULL); ft_bzero(clist->errmsg, 40); - i = 0; - while (i < 5) - { + i = -1; + while (++i < 5) clist->key_input[i] = -1; - i++; - } clist->minimap = 0; clist->f_rgb = ft_init_rgb(); clist->c_rgb = ft_init_rgb(); clist->rlist = ft_init_s_ray(); + clist->key_ptr[0] = ft_w_key; + clist->key_ptr[1] = ft_a_key; + clist->key_ptr[2] = ft_s_key; + clist->key_ptr[3] = ft_d_key; + clist->key_ptr[4] = ft_left_key; + clist->key_ptr[5] = ft_right_key; return (clist); } diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c index b902e33..df163a9 100644 --- a/src/ft_key_loop.c +++ b/src/ft_key_loop.c @@ -13,6 +13,8 @@ #include <libft.h> #include <cub3d.h> #include <stdint.h> +#include <stddef.h> +#include <pthread.h> static void ft_collision(float old_y, float old_x, t_player *pl, t_map *ml) @@ -27,24 +29,23 @@ static void } } +static void +*ft_th_input(void *varg) +{ + return (NULL); +} + int ft_key_loop(t_cub *cl) { - int (*fun_ptr[6])(t_cub*); uint8_t i; const float old_y = cl->plist->pos_y; const float old_x = cl->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; i = 0; while (i < 5 && cl->key_input[i] != -1 && cl->key_input[i] <= 5) { - (*fun_ptr[cl->key_input[i]])(cl); + cl->key_ptr[cl->key_input[i]](cl); ft_collision(old_y, old_x, cl->plist, cl->mlist); ft_draw_scene(cl); i++; |