norm: fix a few norm errors

This commit is contained in:
Khaïs COLIN 2025-08-05 12:53:06 +02:00
parent f21e1e56fb
commit 121db8bd3c
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* move.c :+: :+: :+: */ /* move.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/29 13:58:00 by tchampio #+# #+# */ /* Created: 2025/08/05 12:53:06 by kcolin #+# #+# */
/* Updated: 2025/07/31 14:43:57 by tchampio ### ########.fr */ /* Updated: 2025/08/05 12:53:06 by kcolin ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,14 +19,16 @@ void move_player_forward(t_cub3d_data *data)
char **map; char **map;
double next_x; double next_x;
double next_y; double next_y;
float movspeed;
movspeed = MOVEMENT_SPEED * data->delta;
map = data->map->map; map = data->map->map;
next_x = data->player.x + data->player.dir_x * MOVEMENT_SPEED * data->delta; next_x = data->player.x + data->player.dir_x * movspeed;
next_y = data->player.y + data->player.dir_y * MOVEMENT_SPEED * data->delta; next_y = data->player.y + data->player.dir_y * movspeed;
if (map[(int)data->player.y][(int)next_x] == '0') if (map[(int)data->player.y][(int)next_x] == '0')
data->player.x += data->player.dir_x * MOVEMENT_SPEED * data->delta; data->player.x += data->player.dir_x * movspeed;
if (map[(int)next_y][(int)data->player.x] == '0') if (map[(int)next_y][(int)data->player.x] == '0')
data->player.y += data->player.dir_y * MOVEMENT_SPEED * data->delta; data->player.y += data->player.dir_y * movspeed;
} }
void move_player_backward(t_cub3d_data *data) void move_player_backward(t_cub3d_data *data)
@ -34,14 +36,16 @@ void move_player_backward(t_cub3d_data *data)
char **map; char **map;
double next_x; double next_x;
double next_y; double next_y;
float movspeed;
movspeed = MOVEMENT_SPEED * data->delta;
map = data->map->map; map = data->map->map;
next_x = data->player.x - data->player.dir_x * MOVEMENT_SPEED * data->delta; next_x = data->player.x - data->player.dir_x * movspeed;
next_y = data->player.y - data->player.dir_y * MOVEMENT_SPEED * data->delta; next_y = data->player.y - data->player.dir_y * movspeed;
if (map[(int)data->player.y][(int)next_x] == '0') if (map[(int)data->player.y][(int)next_x] == '0')
data->player.x -= data->player.dir_x * MOVEMENT_SPEED * data->delta; data->player.x -= data->player.dir_x * movspeed;
if (map[(int)next_y][(int)data->player.x] == '0') if (map[(int)next_y][(int)data->player.x] == '0')
data->player.y -= data->player.dir_y * MOVEMENT_SPEED * data->delta; data->player.y -= data->player.dir_y * movspeed;
} }
void move_player_strafe_left(t_cub3d_data *data) void move_player_strafe_left(t_cub3d_data *data)
@ -49,14 +53,16 @@ void move_player_strafe_left(t_cub3d_data *data)
char **map; char **map;
double next_x; double next_x;
double next_y; double next_y;
float movspeed;
movspeed = MOVEMENT_SPEED * data->delta;
map = data->map->map; map = data->map->map;
next_x = data->player.x - data->player.plane_x * MOVEMENT_SPEED * data->delta; next_x = data->player.x - data->player.plane_x * movspeed;
next_y = data->player.y - data->player.plane_y * MOVEMENT_SPEED * data->delta; next_y = data->player.y - data->player.plane_y * movspeed;
if (map[(int)data->player.y][(int)next_x] == '0') if (map[(int)data->player.y][(int)next_x] == '0')
data->player.x -= data->player.plane_x * MOVEMENT_SPEED * data->delta; data->player.x -= data->player.plane_x * movspeed;
if (map[(int)next_y][(int)data->player.x] == '0') if (map[(int)next_y][(int)data->player.x] == '0')
data->player.y -= data->player.plane_y * MOVEMENT_SPEED * data->delta; data->player.y -= data->player.plane_y * movspeed;
} }
void move_player_strafe_right(t_cub3d_data *data) void move_player_strafe_right(t_cub3d_data *data)
@ -64,14 +70,16 @@ void move_player_strafe_right(t_cub3d_data *data)
char **map; char **map;
double next_x; double next_x;
double next_y; double next_y;
float movspeed;
movspeed = MOVEMENT_SPEED * data->delta;
map = data->map->map; map = data->map->map;
next_x = data->player.x + data->player.plane_x * MOVEMENT_SPEED * data->delta; next_x = data->player.x + data->player.plane_x * movspeed;
next_y = data->player.y + data->player.plane_y * MOVEMENT_SPEED * data->delta; next_y = data->player.y + data->player.plane_y * movspeed;
if (map[(int)data->player.y][(int)next_x] == '0') if (map[(int)data->player.y][(int)next_x] == '0')
data->player.x += data->player.plane_x * MOVEMENT_SPEED * data->delta; data->player.x += data->player.plane_x * movspeed;
if (map[(int)next_y][(int)data->player.x] == '0') if (map[(int)next_y][(int)data->player.x] == '0')
data->player.y += data->player.plane_y * MOVEMENT_SPEED * data->delta; data->player.y += data->player.plane_y * movspeed;
} }
void move_player(t_cub3d_data *data) void move_player(t_cub3d_data *data)