Files
42_INT_10_cube3d/srcs/player/player_rotates.c

36 lines
662 B
C

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