From 78fa8c89670b1521d0c33ace770587afde4c5b01 Mon Sep 17 00:00:00 2001 From: Gregory Robledo Date: Tue, 15 Oct 2024 16:35:16 +0200 Subject: [PATCH 1/2] added spawn direction --- algo.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/algo.c b/algo.c index 6eb31c9..dcfea4a 100644 --- a/algo.c +++ b/algo.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* algo.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: mcolonna +#+ +:+ +#+ */ +/* By: grobledo +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/01 16:24:58 by grobledo #+# #+# */ -/* Updated: 2024/10/15 14:10:11 by mcolonna ### ########.fr */ +/* Updated: 2024/10/15 16:34:46 by grobledo ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,15 +44,23 @@ int worldMap[mapWidth][mapHeight] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} }; -static int initalgo() +static int initalgo(char posplayer) { // TODO from map g_ray.posX = 14; - g_ray.posY = 6.5; - g_ray.rot = 0; + g_ray.posY = 17; + if (posplayer == 'N') + g_ray.rot = 0; + if (posplayer == 'S') + g_ray.rot = PI; + if (posplayer == 'W') + g_ray.rot = (3 * PI) / 2; + if (posplayer == 'E') + g_ray.rot = PI/2; return (0); } + void draw_screen(void) { int bpp; int size_line; From 379f2bce6cca370df5b9d06bdece764ef98ee463 Mon Sep 17 00:00:00 2001 From: Gregory Robledo Date: Tue, 15 Oct 2024 16:37:55 +0200 Subject: [PATCH 2/2] added posplayer --- algo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/algo.c b/algo.c index dcfea4a..cdf9fc1 100644 --- a/algo.c +++ b/algo.c @@ -6,7 +6,7 @@ /* By: grobledo +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/01 16:24:58 by grobledo #+# #+# */ -/* Updated: 2024/10/15 16:34:46 by grobledo ### ########.fr */ +/* Updated: 2024/10/15 16:37:29 by grobledo ### ########.fr */ /* */ /* ************************************************************************** */ @@ -93,8 +93,8 @@ int main(void) // Initialisation g_mlx = mlx_init(); g_win = mlx_new_window(g_mlx, SCREEN_WIDTH, SCREEN_HEIGHT, "cub3d"); - - initalgo(); + char posplayer = 'N'; // test + initalgo(posplayer); // hook keypress mlx_hook(g_win, 2, 1L<<0, keypress, NULL);