player rotates and moves, rays for raycasting on map
This commit is contained in:
35
srcs/player/player_rotates.c
Normal file
35
srcs/player/player_rotates.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "cube3d.h"
|
||||
|
||||
void plr_turn_left(t_game *game)
|
||||
{
|
||||
double radi;
|
||||
double radj;
|
||||
|
||||
if (game->rot == -180)
|
||||
(game->rot) *= -1;
|
||||
(game->rot)--;
|
||||
// calculate trigo for rotations
|
||||
radi = game->rot * M_PI / 180;
|
||||
radj = radi + (M_PI / 2);
|
||||
game->cosi = cos(radi);
|
||||
game->sini = sin(radi);
|
||||
game->cosj = cos(radj);
|
||||
game->sinj = sin(radj);
|
||||
}
|
||||
|
||||
void plr_turn_right(t_game *game)
|
||||
{
|
||||
double radi;
|
||||
double radj;
|
||||
|
||||
if (game->rot == 180)
|
||||
(game->rot) *= -1;
|
||||
(game->rot)++;
|
||||
// calculate trigo for rotations
|
||||
radi = game->rot * M_PI / 180;
|
||||
radj = radi + (M_PI / 2);
|
||||
game->cosi = cos(radi);
|
||||
game->sini = sin(radi);
|
||||
game->cosj = cos(radj);
|
||||
game->sinj = sin(radj);
|
||||
}
|
||||
Reference in New Issue
Block a user