Added memorybook to parsing and cleaned most of the files

This commit is contained in:
Philippe BLAGOJEVIC
2022-05-04 14:38:34 +02:00
parent e564e7c8e9
commit 362668fe35
231 changed files with 11474 additions and 405 deletions

View File

@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* key_action_1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/04 13:48:28 by pblagoje #+# #+# */
/* Updated: 2022/05/04 13:49:27 by pblagoje ### ########.fr */
/* */
/* ************************************************************************** */
#include "cube3d.h"
int is_esc(int *k_hook, int *is_action)
@@ -5,9 +17,9 @@ int is_esc(int *k_hook, int *is_action)
if (!ft_arrint(k_hook, KEY_ESC, MAX_NB_KEY))
{
*is_action = 1;
return 1;
return (1);
}
return 0;
return (0);
}
int is_go_left(int *k_hook, int *is_action)
@@ -15,14 +27,14 @@ int is_go_left(int *k_hook, int *is_action)
if (!ft_arrint(k_hook, KEY_A, MAX_NB_KEY))
{
*is_action = 1;
return 1;
return (1);
}
if (!ft_arrint(k_hook, KEY_Q, MAX_NB_KEY))
{
*is_action = 1;
return 1;
return (1);
}
return 0;
return (0);
}
int is_go_right(int *k_hook, int *is_action)
@@ -30,9 +42,9 @@ int is_go_right(int *k_hook, int *is_action)
if (!ft_arrint(k_hook, KEY_D, MAX_NB_KEY))
{
*is_action = 1;
return 1;
return (1);
}
return 0;
return (0);
}
int is_go_forward(int *k_hook, int *is_action)
@@ -40,14 +52,14 @@ int is_go_forward(int *k_hook, int *is_action)
if (!ft_arrint(k_hook, KEY_W, MAX_NB_KEY))
{
*is_action = 1;
return 1;
return (1);
}
if (!ft_arrint(k_hook, KEY_Z, MAX_NB_KEY))
{
*is_action = 1;
return 1;
return (1);
}
return 0;
return (0);
}
int is_go_backward(int *k_hook, int *is_action)
@@ -55,7 +67,7 @@ int is_go_backward(int *k_hook, int *is_action)
if (!ft_arrint(k_hook, KEY_S, MAX_NB_KEY))
{
*is_action = 1;
return 1;
return (1);
}
return 0;
return (0);
}

View File

@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* key_action_2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/04 13:48:54 by pblagoje #+# #+# */
/* Updated: 2022/05/04 13:48:56 by pblagoje ### ########.fr */
/* */
/* ************************************************************************** */
#include "cube3d.h"
int is_turn_left(int *k_hook, int *is_action)
@@ -5,9 +17,9 @@ int is_turn_left(int *k_hook, int *is_action)
if (!ft_arrint(k_hook, ARROW_LEFT, MAX_NB_KEY))
{
*is_action = 1;
return 1;
return (1);
}
return 0;
return (0);
}
int is_turn_right(int *k_hook, int *is_action)
@@ -15,7 +27,7 @@ int is_turn_right(int *k_hook, int *is_action)
if (!ft_arrint(k_hook, ARROW_RIGHT, MAX_NB_KEY))
{
*is_action = 1;
return 1;
return (1);
}
return 0;
return (0);
}

View File

@@ -1,15 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* keyhook.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/04 13:45:52 by pblagoje #+# #+# */
/* Updated: 2022/05/04 13:47:13 by pblagoje ### ########.fr */
/* */
/* ************************************************************************** */
#include "cube3d.h"
// temp, to map all the keys on linux and mac
static int print_keycode(int keycode, t_plr *plr)
{
ft_putnbr_fd(keycode, 1);
ft_putchar_fd(' ', 1);
ft_putnbr_fd(plr->rot, 1);
ft_putchar_fd('\n', 1);
return(0);
}
// temp end
static int print_keycode(int keycode, t_plr *plr)
{
ft_putnbr_fd(keycode, 1);
ft_putchar_fd(' ', 1);
ft_putnbr_fd(plr->rot, 1);
ft_putchar_fd('\n', 1);
return (0);
}
int hook_action(t_game *game)
{
@@ -30,40 +40,16 @@ int hook_action(t_game *game)
plr_turn_left(&(game->plr));
if (is_turn_right(game->k_hook, &is_action))
plr_turn_right(&(game->plr));
// tmp draw map
// // ray
// if (!ft_arrint(game->k_hook, 65364, MAX_NB_KEY))
// {
// if (game->ray_highlight <= SCREEN_WIDTH)
// game->ray_highlight++;
// else
// game->ray_highlight = -1;
// is_action = 1;
// }
// if (!ft_arrint(game->k_hook, 65362, MAX_NB_KEY))
// {
// if (game->ray_highlight >= 0)
// game->ray_highlight--;
// else
// game->ray_highlight = SCREEN_WIDTH;
// is_action = 1;
// }
// tmp end
if (is_action)
draw(game);
return(0);
return (0);
}
int keypress(int keycode, t_game *game)
int keypress(int keycode, t_game *game)
{
unsigned i;
// temp
print_keycode(keycode, &game->plr);
// temp end
print_keycode(keycode, &game->plr);
i = 0;
while (i < MAX_NB_KEY && game->k_hook[i] != 0 && game->k_hook[i] != keycode)
i++;
@@ -71,11 +57,10 @@ int keypress(int keycode, t_game *game)
game->k_hook[i] = 0;
else if (i < MAX_NB_KEY)
game->k_hook[i] = keycode;
// hook_action(game);
return (0);
}
int keyrelease(int keycode, t_game *game)
int keyrelease(int keycode, t_game *game)
{
unsigned i;