mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
norm: fix a few norm errors
This commit is contained in:
parent
f21e1e56fb
commit
121db8bd3c
1 changed files with 27 additions and 19 deletions
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* move.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/29 13:58:00 by tchampio #+# #+# */
|
||||
/* Updated: 2025/07/31 14:43:57 by tchampio ### ########.fr */
|
||||
/* Created: 2025/08/05 12:53:06 by kcolin #+# #+# */
|
||||
/* Updated: 2025/08/05 12:53:06 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,14 +19,16 @@ void move_player_forward(t_cub3d_data *data)
|
|||
char **map;
|
||||
double next_x;
|
||||
double next_y;
|
||||
float movspeed;
|
||||
|
||||
movspeed = MOVEMENT_SPEED * data->delta;
|
||||
map = data->map->map;
|
||||
next_x = data->player.x + data->player.dir_x * MOVEMENT_SPEED * data->delta;
|
||||
next_y = data->player.y + data->player.dir_y * MOVEMENT_SPEED * data->delta;
|
||||
next_x = data->player.x + data->player.dir_x * movspeed;
|
||||
next_y = data->player.y + data->player.dir_y * movspeed;
|
||||
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')
|
||||
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)
|
||||
|
|
@ -34,14 +36,16 @@ void move_player_backward(t_cub3d_data *data)
|
|||
char **map;
|
||||
double next_x;
|
||||
double next_y;
|
||||
float movspeed;
|
||||
|
||||
movspeed = MOVEMENT_SPEED * data->delta;
|
||||
map = data->map->map;
|
||||
next_x = data->player.x - data->player.dir_x * MOVEMENT_SPEED * data->delta;
|
||||
next_y = data->player.y - data->player.dir_y * MOVEMENT_SPEED * data->delta;
|
||||
next_x = data->player.x - data->player.dir_x * movspeed;
|
||||
next_y = data->player.y - data->player.dir_y * movspeed;
|
||||
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')
|
||||
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)
|
||||
|
|
@ -49,14 +53,16 @@ void move_player_strafe_left(t_cub3d_data *data)
|
|||
char **map;
|
||||
double next_x;
|
||||
double next_y;
|
||||
float movspeed;
|
||||
|
||||
movspeed = MOVEMENT_SPEED * data->delta;
|
||||
map = data->map->map;
|
||||
next_x = data->player.x - data->player.plane_x * MOVEMENT_SPEED * data->delta;
|
||||
next_y = data->player.y - data->player.plane_y * MOVEMENT_SPEED * data->delta;
|
||||
next_x = data->player.x - data->player.plane_x * movspeed;
|
||||
next_y = data->player.y - data->player.plane_y * movspeed;
|
||||
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')
|
||||
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)
|
||||
|
|
@ -64,14 +70,16 @@ void move_player_strafe_right(t_cub3d_data *data)
|
|||
char **map;
|
||||
double next_x;
|
||||
double next_y;
|
||||
float movspeed;
|
||||
|
||||
movspeed = MOVEMENT_SPEED * data->delta;
|
||||
map = data->map->map;
|
||||
next_x = data->player.x + data->player.plane_x * MOVEMENT_SPEED * data->delta;
|
||||
next_y = data->player.y + data->player.plane_y * MOVEMENT_SPEED * data->delta;
|
||||
next_x = data->player.x + data->player.plane_x * movspeed;
|
||||
next_y = data->player.y + data->player.plane_y * movspeed;
|
||||
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')
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue