Files
42_INT_10_cube3d/srcs/hook/key_do_action.c

44 lines
1.0 KiB
C

#include "cube3d.h"
// temp, to test keypress hook
void keypress_do_action(t_game *game)
{
int is_action;
is_action = 0;
if (is_esc(game->k_hook, &is_action))
shut_down(game);
if (is_go_left(game->k_hook, &is_action))
plr_posx_decrement(game);
if (is_go_right(game->k_hook, &is_action))
plr_posx_increment(game);
if (is_go_forward(game->k_hook, &is_action))
plr_posy_decrement(game);
if (is_go_backward(game->k_hook, &is_action))
plr_posy_increment(game);
if (is_turn_left(game->k_hook, &is_action))
plr_turn_left(game);
if (is_turn_right(game->k_hook, &is_action))
plr_turn_right(game);
// temp display one ray with infos
if (!ft_arrintchr(game->k_hook, 65364, MAX_NB_KEY))
{
if (game->ray_highlight <= SCREEN_DEF)
game->ray_highlight++;
else
game->ray_highlight = -1;
is_action = 1;
}
if (!ft_arrintchr(game->k_hook, 65362, MAX_NB_KEY))
{
if (game->ray_highlight >= 0)
game->ray_highlight--;
else
game->ray_highlight = SCREEN_DEF;
is_action = 1;
}
// temp end
if (is_action)
draw(game);
}