plr moves through walls
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
# todo
|
||||
|
||||
- resolve view buble
|
||||
- add slide against wall
|
||||
- resolve vertical ray
|
||||
- add textures
|
||||
|
||||
# ressources
|
||||
|
||||
- [tuto mlx](https://harm-smits.github.io/42docs/libs/minilibx/getting_started.html)
|
||||
|
||||
@@ -55,8 +55,8 @@ void rotate_double(t_plr *plr, t_d_coord *coord);
|
||||
void plr_turn_right(t_plr *plr);
|
||||
void plr_turn_left(t_plr *plr);
|
||||
// player_limits.c
|
||||
int plr_out_limits(t_game *game, int x, int y);
|
||||
int is_wall(t_game *game, int cell_x, int cell_y);
|
||||
int plr_out_limits(t_game *game, int x, int y);
|
||||
|
||||
// -------------------------------
|
||||
// SRC/DRAW
|
||||
|
||||
@@ -3,12 +3,18 @@
|
||||
void plr_posx_decrement(t_game *game, t_plr *plr)
|
||||
{
|
||||
t_d_coord pos;
|
||||
int limit_x;
|
||||
int limit_y;
|
||||
|
||||
pos.x = plr->exact.x - PLR_MV;
|
||||
pos.y = plr->exact.y;
|
||||
rotate_double(plr, &pos);
|
||||
if (plr_out_limits(game, pos.x, pos.y))
|
||||
return ;
|
||||
limit_x = plr_out_limits(game, pos.x, plr->pos.y);
|
||||
limit_y = plr_out_limits(game, plr->pos.x, pos.y);
|
||||
if (limit_x)
|
||||
pos.x = plr->exact.x;
|
||||
if (limit_y)
|
||||
pos.y = plr->exact.y;
|
||||
plr->exact.x = pos.x;
|
||||
plr->exact.y = pos.y;
|
||||
(plr->pos.x) = (int)(pos.x);
|
||||
@@ -18,12 +24,18 @@ void plr_posx_decrement(t_game *game, t_plr *plr)
|
||||
void plr_posy_decrement(t_game *game, t_plr *plr)
|
||||
{
|
||||
t_d_coord pos;
|
||||
int limit_x;
|
||||
int limit_y;
|
||||
|
||||
pos.x = plr->exact.x;
|
||||
pos.y = plr->exact.y - PLR_MV;
|
||||
rotate_double(plr, &(pos));
|
||||
if (plr_out_limits(game, pos.x, pos.y))
|
||||
return ;
|
||||
limit_x = plr_out_limits(game, pos.x, plr->pos.y);
|
||||
limit_y = plr_out_limits(game, plr->pos.x, pos.y);
|
||||
if (limit_x)
|
||||
pos.x = plr->exact.x;
|
||||
if (limit_y)
|
||||
pos.y = plr->exact.y;
|
||||
plr->exact.x = pos.x;
|
||||
plr->exact.y = pos.y;
|
||||
(plr->pos.x) = (int)(pos.x);
|
||||
@@ -33,12 +45,18 @@ void plr_posy_decrement(t_game *game, t_plr *plr)
|
||||
void plr_posx_increment(t_game *game, t_plr *plr)
|
||||
{
|
||||
t_d_coord pos;
|
||||
int limit_x;
|
||||
int limit_y;
|
||||
|
||||
pos.x = plr->exact.x + PLR_MV;
|
||||
pos.y = plr->exact.y;
|
||||
rotate_double(plr, &(pos));
|
||||
if (plr_out_limits(game, pos.x, pos.y))
|
||||
return ;
|
||||
limit_x = plr_out_limits(game, pos.x, plr->pos.y);
|
||||
limit_y = plr_out_limits(game, plr->pos.x, pos.y);
|
||||
if (limit_x)
|
||||
pos.x = plr->exact.x;
|
||||
if (limit_y)
|
||||
pos.y = plr->exact.y;
|
||||
plr->exact.x = pos.x;
|
||||
plr->exact.y = pos.y;
|
||||
(plr->pos.x) = (int)(pos.x);
|
||||
@@ -48,12 +66,18 @@ void plr_posx_increment(t_game *game, t_plr *plr)
|
||||
void plr_posy_increment(t_game *game, t_plr *plr)
|
||||
{
|
||||
t_d_coord pos;
|
||||
int limit_x;
|
||||
int limit_y;
|
||||
|
||||
pos.x = plr->exact.x;
|
||||
pos.y = plr->exact.y + PLR_MV;
|
||||
rotate_double(plr, &(pos));
|
||||
if (plr_out_limits(game, pos.x, pos.y))
|
||||
return ;
|
||||
limit_x = plr_out_limits(game, pos.x, plr->pos.y);
|
||||
limit_y = plr_out_limits(game, plr->pos.x, pos.y);
|
||||
if (limit_x)
|
||||
pos.x = plr->exact.x;
|
||||
if (limit_y)
|
||||
pos.y = plr->exact.y;
|
||||
plr->exact.x = pos.x;
|
||||
plr->exact.y = pos.y;
|
||||
(plr->pos.x) = (int)(pos.x);
|
||||
|
||||
Reference in New Issue
Block a user