start project with header, struct, mlx functionnal, and basic key event action

This commit is contained in:
hugogogo
2022-03-23 14:27:36 +01:00
parent 1959a1a9a3
commit 95bd304708
11 changed files with 228 additions and 1 deletions

38
srcs/hook/keyhook.c Normal file
View File

@@ -0,0 +1,38 @@
#include "cube3d.h"
// temp, to map all the keys on linux and mac
static int print_keycode(int keycode)
{
ft_putnbrendl(keycode);
return(0);
}
// temp end
static void keypress_action(int keycode, t_game *game)
{
// escape
if (keycode == 65307)
shut_down(game);
// left
if (keycode == 65361)
(game->plr_x) -= 5;
// right
if (keycode == 65363)
(game->plr_x) += 5;
// up
if (keycode == 65362)
(game->plr_y) -= 5;
// down
if (keycode == 65364)
(game->plr_y) += 5;
mlx_pixel_put(game->mlx_ptr, game->win_ptr, game->plr_x, game->plr_y, 0x74db74);
}
int keypress(int keycode, t_game *game)
{
// temp
print_keycode(keycode);
keypress_action(keycode, game);
return (0);
}