aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d_structs.h1
-rw-r--r--src/ft_basic_keys.c4
-rw-r--r--src/ft_draw_handweap.c8
-rw-r--r--src/ft_draw_life_bar.c4
-rw-r--r--src/ft_init_lists.c1
-rw-r--r--src/ft_key_loop.c1
6 files changed, 15 insertions, 4 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index cd711ba..f538c7e 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -239,6 +239,7 @@ typedef struct s_cub
char fps_count[9];
pthread_t mtid;
int8_t isdead;
+ uint8_t moves;
int (*key_ptr[6])(struct s_cub*);
int8_t (*get_ptr[14])(char**, struct s_cub*);
char ref[22][3];
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);