rot camera vector

This commit is contained in:
Willem Haffmans 2025-05-02 17:01:05 +02:00
parent dbd8d2c217
commit 8ba694a25a
2 changed files with 4 additions and 0 deletions

View File

@ -11,6 +11,7 @@
/* ************************************************************************** */ /* ************************************************************************** */
#include "cub3d.h" #include "cub3d.h"
#include <math.h>
t_vec2 parse_dir(int x, int y) t_vec2 parse_dir(int x, int y)
{ {
@ -37,6 +38,8 @@ int parse_player(t_game *game, int y, int x, char c)
player->dir = parse_dir(0, -1); player->dir = parse_dir(0, -1);
else if (c == 'W') else if (c == 'W')
player->dir = parse_dir(-1, 0); player->dir = parse_dir(-1, 0);
player->camera = rot(player->dir, 0.5f * M_PI);
return (SUCCESS); return (SUCCESS);
} }

View File

@ -53,6 +53,7 @@ static void rotate(t_player *player, float rot_speed)
// // player->dir.x = player->dir.x * cos(rot_speed) - player->dir.y * sin(rot_speed); // // player->dir.x = player->dir.x * cos(rot_speed) - player->dir.y * sin(rot_speed);
// // player->dir.y = old_x * sin(rot_speed) + player->dir.y * cos(rot_speed); // // player->dir.y = old_x * sin(rot_speed) + player->dir.y * cos(rot_speed);
player->dir = rot(player->dir, rot_speed); player->dir = rot(player->dir, rot_speed);
player->camera = rot(player->camera, rot_speed);
} }
void player_update(t_game *game, float delta_time) void player_update(t_game *game, float delta_time)