From c821373154aa7e475020c051f884416c68969abe Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Fri, 10 May 2024 13:07:27 +0200 Subject: [PATCH] Add delta_time to player movement --- include/so_long.h | 6 +++--- src/loop.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/so_long.h b/include/so_long.h index 7365a30..d66e355 100644 --- a/include/so_long.h +++ b/include/so_long.h @@ -13,7 +13,7 @@ #ifndef SO_LONG_H # define SO_LONG_H -# define PLAYER_MOVE_SPEED 3 +# define PLAYER_MOVE_SPEED 250 # include "MLX42/MLX42.h" # include "libft.h" @@ -28,8 +28,8 @@ enum e_direction typedef struct s_vector { - int x; - int y; + double x; + double y; } t_vector; typedef struct s_player diff --git a/src/loop.c b/src/loop.c index 6162935..18590a5 100644 --- a/src/loop.c +++ b/src/loop.c @@ -6,7 +6,7 @@ /* By: dkaiser input_direction & LEFT) != 0); game->player.direction.y = ((game->input_direction & DOWN) != 0) - ((game->input_direction & UP) != 0); - game->player.position.x += game->player.direction.x * PLAYER_MOVE_SPEED; - game->player.position.y += game->player.direction.y * PLAYER_MOVE_SPEED; + game->player.position.x += game->player.direction.x * PLAYER_MOVE_SPEED * game->mlx->delta_time; + game->player.position.y += game->player.direction.y * PLAYER_MOVE_SPEED * game->mlx->delta_time; draw(game); } -- 2.47.2