player rotates and moves, rays for raycasting on map

This commit is contained in:
Hugo LAMY
2022-04-18 18:27:16 +02:00
parent 00b3612c16
commit 01eb2255d2
21 changed files with 689 additions and 138 deletions

View 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);
}