diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-20 19:33:03 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-20 19:33:03 +0100 |
commit | ad0b32676e8ab435ea5767f7ca37496bf15df714 (patch) | |
tree | e33ded21db111ecfa4a96f1a718a6ef1cafc8a02 /src | |
parent | it's not working (diff) | |
download | 42-cub3d-ad0b32676e8ab435ea5767f7ca37496bf15df714.tar.gz 42-cub3d-ad0b32676e8ab435ea5767f7ca37496bf15df714.tar.bz2 42-cub3d-ad0b32676e8ab435ea5767f7ca37496bf15df714.tar.xz 42-cub3d-ad0b32676e8ab435ea5767f7ca37496bf15df714.tar.zst 42-cub3d-ad0b32676e8ab435ea5767f7ca37496bf15df714.zip |
Better bounce
Diffstat (limited to '')
-rw-r--r-- | src/ft_basic_keys.c | 4 | ||||
-rw-r--r-- | src/ft_draw_handweap.c | 8 | ||||
-rw-r--r-- | src/ft_draw_life_bar.c | 4 | ||||
-rw-r--r-- | src/ft_init_lists.c | 1 | ||||
-rw-r--r-- | src/ft_key_loop.c | 1 |
5 files changed, 14 insertions, 4 deletions
diff --git a/src/ft_basic_keys.c b/src/ft_basic_keys.c index 29044d9..471038b 100644 --- a/src/ft_basic_keys.c +++ b/src/ft_basic_keys.c @@ -22,6 +22,7 @@ int pl = &clist->plist; pl->pos_y += move_speed * pl->dir_x; pl->pos_x += move_speed * pl->dir_y; + clist->moves = 1; return (0); } @@ -34,6 +35,7 @@ int pl = &clist->plist; pl->pos_y += move_speed * -pl->dir_y; pl->pos_x += move_speed * pl->dir_x; + clist->moves = 1; return (0); } @@ -46,6 +48,7 @@ int pl = &clist->plist; pl->pos_y += move_speed * -pl->dir_x; pl->pos_x += move_speed * -pl->dir_y; + clist->moves = 1; return (0); } @@ -58,5 +61,6 @@ int pl = &clist->plist; pl->pos_y += move_speed * pl->dir_y; pl->pos_x += move_speed * -pl->dir_x; + clist->moves = 1; return (0); } diff --git a/src/ft_draw_handweap.c b/src/ft_draw_handweap.c index 607cb9a..f171c42 100644 --- a/src/ft_draw_handweap.c +++ b/src/ft_draw_handweap.c @@ -28,18 +28,22 @@ static void } static int16_t - ft_set_move(void) + ft_set_move(t_cub *cl) { static int8_t more = 0; static int8_t less = 39; if (more < 38) { + if (!cl->moves) + return (more); more += FT_BOUNCE_FACTOR; return (more); } else { + if (!cl->moves) + return (less); less -= FT_BOUNCE_FACTOR; if (less < 1) { @@ -67,7 +71,7 @@ void x_ratio = (int32_t)(((cl->tweap[w_id].img_w - 50) << 16) / cl->wlist.x_size) + 1; y_ratio = (int32_t)(((cl->tweap[w_id].img_h - 50) << 16) / cl->wlist.y_size) + 1; y = 0; - move = ft_set_move(); + move = ft_set_move(cl); move = (cl->plist.fire == 1) ? (0) : (move); while (y < (int16_t)cl->wlist.y_size) { diff --git a/src/ft_draw_life_bar.c b/src/ft_draw_life_bar.c index 8e3da2c..80ec63e 100644 --- a/src/ft_draw_life_bar.c +++ b/src/ft_draw_life_bar.c @@ -41,8 +41,8 @@ static void int32_t x; int32_t y; - x_ratio = (int)((cl->tnum[10].img_w << 16) / (cl->mlist.map_w * cl->mlist.scale)) + 1; - y_ratio = (int)((cl->tnum[10].img_h << 16) / (cl->mlist.map_h * cl->mlist.scale)) + 1; + x_ratio = (int)((cl->tnum[10].img_w << 16) / (cl->mlist.map_w * cl->mlist.scale) - 10) + 1; + y_ratio = (int)((cl->tnum[10].img_h << 16) / (cl->mlist.map_h * cl->mlist.scale) - 10) + 1; y = cl->wlist.y_size - (cl->mlist.map_h * cl->mlist.scale) - 10; while (y < (int32_t)(cl->wlist.y_size - (cl->mlist.map_h * cl->mlist.scale) - 10 + (8 * cl->mlist.scale))) { diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index 5e862ce..d1b589e 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -110,5 +110,6 @@ int8_t return (-1); ft_sprintf(clist->fps_count, "fps: 60"); clist->isdead = 0; + clist->moves = 0; return (0); } diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c index cf412f7..77f2d7d 100644 --- a/src/ft_key_loop.c +++ b/src/ft_key_loop.c @@ -102,6 +102,7 @@ int } i++; } + cl->moves = (cl->key_input[0] == -1) ? (0) : (cl->moves); begin_frame = clock(); ft_draw_scene(cl); ft_get_fps_count(clock() - begin_frame, cl); |