fix: norme compliance

This commit is contained in:
Theo Champion 2025-07-29 20:13:43 +02:00
parent b6eeea5e9f
commit 788f248c5e
4 changed files with 33 additions and 25 deletions

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/24 14:41:35 by tchampio #+# #+# */
/* Updated: 2025/07/29 19:47:18 by tchampio ### ########.fr */
/* Updated: 2025/07/29 20:09:55 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,21 +17,6 @@
#include <math.h>
#include "player.h"
void turn_left_angle(t_cub3d_data *data)
{
t_player *p;
double prev_dir_x;
double prev_plane_x;
p = &data->player;
prev_dir_x = p->dir_x;
prev_plane_x = p->plane_x;
p->dir_x = p->dir_x * cos(ROTATION_SPEED) - p->dir_y * sin(ROTATION_SPEED);
p->dir_y = prev_dir_x * sin(ROTATION_SPEED) + p->dir_y * cos(ROTATION_SPEED);
p->plane_x = p->plane_x * cos(ROTATION_SPEED) - p->plane_y * sin(ROTATION_SPEED);
p->plane_y = prev_plane_x * sin(ROTATION_SPEED) + p->plane_y * cos(ROTATION_SPEED);
}
void turn_right_angle(t_cub3d_data *data)
{
t_player *p;
@ -41,8 +26,30 @@ void turn_right_angle(t_cub3d_data *data)
p = &data->player;
prev_dir_x = p->dir_x;
prev_plane_x = p->plane_x;
p->dir_x = p->dir_x * cos(-ROTATION_SPEED) - p->dir_y * sin(-ROTATION_SPEED);
p->dir_y = prev_dir_x * sin(-ROTATION_SPEED) + p->dir_y * cos(-ROTATION_SPEED);
p->plane_x = p->plane_x * cos(-ROTATION_SPEED) - p->plane_y * sin(-ROTATION_SPEED);
p->plane_y = prev_plane_x * sin(-ROTATION_SPEED) + p->plane_y * cos(-ROTATION_SPEED);
p->dir_x = p->dir_x * cos(ROTATION_SPEED) - p->dir_y * sin(ROTATION_SPEED);
p->dir_y = prev_dir_x * sin(ROTATION_SPEED)
+ p->dir_y * cos(ROTATION_SPEED);
p->plane_x = p->plane_x * cos(ROTATION_SPEED)
- p->plane_y * sin(ROTATION_SPEED);
p->plane_y = prev_plane_x * sin(ROTATION_SPEED)
+ p->plane_y * cos(ROTATION_SPEED);
}
void turn_left_angle(t_cub3d_data *data)
{
t_player *p;
double prev_dir_x;
double prev_plane_x;
p = &data->player;
prev_dir_x = p->dir_x;
prev_plane_x = p->plane_x;
p->dir_x = p->dir_x * cos(-ROTATION_SPEED)
- p->dir_y * sin(-ROTATION_SPEED);
p->dir_y = prev_dir_x * sin(-ROTATION_SPEED)
+ p->dir_y * cos(-ROTATION_SPEED);
p->plane_x = p->plane_x * cos(-ROTATION_SPEED)
- p->plane_y * sin(-ROTATION_SPEED);
p->plane_y = prev_plane_x * sin(-ROTATION_SPEED)
+ p->plane_y * cos(-ROTATION_SPEED);
}

View file

@ -6,14 +6,14 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/29 13:58:49 by tchampio #+# #+# */
/* Updated: 2025/07/29 13:59:29 by tchampio ### ########.fr */
/* Updated: 2025/07/29 20:13:08 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MOVE_H
# define MOVE_H
#include "../cub3d_data.h"
# include "../cub3d_data.h"
void move_player(t_cub3d_data *data);

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/29 11:42:44 by tchampio #+# #+# */
/* Updated: 2025/07/29 14:44:44 by tchampio ### ########.fr */
/* Updated: 2025/07/29 20:13:01 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -32,6 +32,7 @@ void init_lon(t_player *player, char dir)
player->plane_y = 0;
}
}
// north south
void init_lat(t_player *player, char dir)
{

View file

@ -6,14 +6,14 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/29 13:42:39 by tchampio #+# #+# */
/* Updated: 2025/07/29 13:43:14 by tchampio ### ########.fr */
/* Updated: 2025/07/29 20:09:30 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef KEYPRESSES_H
# define KEYPRESSES_H
typedef struct s_keypresses
typedef struct s_keypresses
{
bool is_w_pressed;
bool is_a_pressed;