Added memorybook to parsing and cleaned most of the files
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* player_rotates.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/05/04 13:49:40 by pblagoje #+# #+# */
|
||||
/* Updated: 2022/05/04 13:49:57 by pblagoje ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cube3d.h"
|
||||
|
||||
void rotate(t_plr *plr, t_coord *coord)
|
||||
@@ -5,17 +17,13 @@ void rotate(t_plr *plr, t_coord *coord)
|
||||
int old_x;
|
||||
t_coord tmp;
|
||||
|
||||
// do nothing if not rotating
|
||||
if (plr->rot == 0)
|
||||
return ;
|
||||
// offset center
|
||||
tmp.x = coord->x - plr->pos.x;
|
||||
tmp.y = coord->y - plr->pos.y;
|
||||
// calculate new coordinates
|
||||
old_x = tmp.x;
|
||||
tmp.x = tmp.x * plr->cosi + tmp.y * plr->cosj;
|
||||
tmp.y = old_x * plr->sini + tmp.y * plr->sinj;
|
||||
// de-offset center
|
||||
coord->x = tmp.x + plr->pos.x;
|
||||
coord->y = tmp.y + plr->pos.y;
|
||||
}
|
||||
@@ -25,17 +33,13 @@ void rotate_double(t_plr *plr, t_d_coord *coord)
|
||||
double old_x;
|
||||
t_d_coord tmp;
|
||||
|
||||
// do nothing if not rotating
|
||||
if (plr->rot == 0)
|
||||
return ;
|
||||
// offset center
|
||||
tmp.x = coord->x - plr->exact.x;
|
||||
tmp.y = coord->y - plr->exact.y;
|
||||
// calculate new coordinates
|
||||
old_x = tmp.x;
|
||||
tmp.x = tmp.x * plr->cosi + tmp.y * plr->cosj;
|
||||
tmp.y = old_x * plr->sini + tmp.y * plr->sinj;
|
||||
// de-offset center
|
||||
coord->x = tmp.x + plr->exact.x;
|
||||
coord->y = tmp.y + plr->exact.y;
|
||||
}
|
||||
@@ -48,7 +52,6 @@ void plr_turn(t_plr *plr, int deg)
|
||||
if (plr->rot == -180)
|
||||
(plr->rot) *= -1;
|
||||
plr->rot += deg;
|
||||
// calculate trigo for rotations
|
||||
radi = plr->rot * M_PI / 180;
|
||||
radj = radi + (M_PI / 2);
|
||||
plr->cosi = cos(radi);
|
||||
|
||||
Reference in New Issue
Block a user