player rotates and moves, rays for raycasting on map
This commit is contained in:
65
srcs/player/player_moves.c
Normal file
65
srcs/player/player_moves.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "cube3d.h"
|
||||
|
||||
void plr_posx_decrement(t_game *game)
|
||||
{
|
||||
double pos_x;
|
||||
double pos_y;
|
||||
|
||||
pos_x = game->plr_exact_x - 5;
|
||||
pos_y = game->plr_exact_y;
|
||||
rotate_double(game, &pos_x, &pos_y);
|
||||
if (plr_out_limits(game, pos_x, pos_y))
|
||||
return ;
|
||||
game->plr_exact_x = pos_x;
|
||||
game->plr_exact_y = pos_y;
|
||||
(game->plr_x) = (int)pos_x;
|
||||
(game->plr_y) = (int)pos_y;
|
||||
}
|
||||
|
||||
void plr_posy_decrement(t_game *game)
|
||||
{
|
||||
double pos_x;
|
||||
double pos_y;
|
||||
|
||||
pos_x = game->plr_exact_x;
|
||||
pos_y = game->plr_exact_y - 5;
|
||||
rotate_double(game, &pos_x, &pos_y);
|
||||
if (plr_out_limits(game, pos_x, pos_y))
|
||||
return ;
|
||||
game->plr_exact_x = pos_x;
|
||||
game->plr_exact_y = pos_y;
|
||||
(game->plr_x) = (int)pos_x;
|
||||
(game->plr_y) = (int)pos_y;
|
||||
}
|
||||
|
||||
void plr_posx_increment(t_game *game)
|
||||
{
|
||||
double pos_x;
|
||||
double pos_y;
|
||||
|
||||
pos_x = game->plr_exact_x + 5;
|
||||
pos_y = game->plr_exact_y;
|
||||
rotate_double(game, &pos_x, &pos_y);
|
||||
if (plr_out_limits(game, pos_x, pos_y))
|
||||
return ;
|
||||
game->plr_exact_x = pos_x;
|
||||
game->plr_exact_y = pos_y;
|
||||
(game->plr_x) = (int)pos_x;
|
||||
(game->plr_y) = (int)pos_y;
|
||||
}
|
||||
|
||||
void plr_posy_increment(t_game *game)
|
||||
{
|
||||
double pos_x;
|
||||
double pos_y;
|
||||
|
||||
pos_x = game->plr_exact_x;
|
||||
pos_y = game->plr_exact_y + 5;
|
||||
rotate_double(game, &pos_x, &pos_y);
|
||||
if (plr_out_limits(game, pos_x, pos_y))
|
||||
return ;
|
||||
game->plr_exact_x = pos_x;
|
||||
game->plr_exact_y = pos_y;
|
||||
(game->plr_x) = (int)pos_x;
|
||||
(game->plr_y) = (int)pos_y;
|
||||
}
|
||||
Reference in New Issue
Block a user