diff --git a/assets/maps/map2.cub b/assets/maps/map2.cub index 736a428..eee5a31 100755 --- a/assets/maps/map2.cub +++ b/assets/maps/map2.cub @@ -1,12 +1,10 @@ - +EA assets/textures/wallTlou.png +F 30,55,55 +C 255,255,255 NO assets/textures/wallTlou.png SO assets/textures/wallTlou.png WE assets/textures/wallTlou.png -EA assets/textures/wallTlou.png - -F 30,55,55 -C 255,255,255 1111111111111111111 1000100001000100001 @@ -17,5 +15,5 @@ C 255,255,255 1000000000000000001 1000001000100000101 1000000000000000001 -10000000N0000000001 -1111111111111111111 \ No newline at end of file +100000N000000000011 +1111111111111111111 diff --git a/assets/maps/maptmp.cub b/assets/maps/maptmp.cub new file mode 100644 index 0000000..2a37fd0 --- /dev/null +++ b/assets/maps/maptmp.cub @@ -0,0 +1,17 @@ +EA assets/textures/wallTlou.png +F 30,55,55 +C 255,255,255 + +NO assets/textures/wallTlou.png +SO assets/textures/wallTlou.png +WE assets/textures/wallTlou.png + +1111111111111111111111111111 +1000000000000000000000000001 +1000000000000000000000000001 +1000000000000000000000000001 +1000000000000E00000000000001 +1000000000000000000000000001 +1000000000000000000000000001 +1000000000000000000000000001 +1111111111111111111111111111 diff --git a/includes/cub3d.h b/includes/cub3d.h index ea8d80e..d81a93a 100755 --- a/includes/cub3d.h +++ b/includes/cub3d.h @@ -6,7 +6,7 @@ /* By: aortigos dt->sq_map[mlx->dt->p_y][mlx->dt->p_x]; - if (c == 'N') // North - faceing up - mlx->ply->angle = M_PI / 2; - if (c == 'S') // South - facing down - mlx->ply->angle = 3 * M_PI / 2; - if (c == 'E') // East - facing right + + c = mlx->dt->sq_map[mlx->dt->p_y][mlx->dt->p_x]; + + if (c == 'N') // Norte - mira hacia ARRIBA (Y negativo) + mlx->ply->angle = 3 * M_PI / 2; // 270° (no 90°) + + if (c == 'S') // Sur - mira hacia ABAJO (Y positivo) + mlx->ply->angle = M_PI / 2; // 90° (no 270°) + + if (c == 'E') // Este - mira hacia DERECHA (X positivo) mlx->ply->angle = 0; - if (c == 'W') // West - facing left - mlx->ply->angle = M_PI; - //Center player in starting cell + + if (c == 'W') // Oeste - mira hacia IZQUIERDA (X negativo) + mlx->ply->angle = M_PI; // 180° + mlx->ply->plyr_x = (mlx->dt->p_x * WALL_SIZE) + WALL_SIZE / 2; mlx->ply->plyr_y = (mlx->dt->p_y * WALL_SIZE) + WALL_SIZE / 2; - mlx->ply->fov_rd = (FOV * M_PI / 180); // Fov from degrees to radians + mlx->ply->fov_rd = (FOV * M_PI / 180); } int execution(t_data *dt) diff --git a/src/execution/movement.c b/src/execution/movement.c index e1f343d..f551c7d 100755 --- a/src/execution/movement.c +++ b/src/execution/movement.c @@ -6,7 +6,7 @@ /* By: aortigos 1) - return (ft_putstr_fd("Invalid map\n", 2), 0); + { + ft_putstr_fd(ERR_MAP_ONE, 2); + return (0); + } // Must have one player spawn if (flag == 0) - return (ft_putstr_fd("no position map\n", 2), 0); + { + ft_putstr_fd(ERR_MAP_SPAWN, 2); + return (0); + } return (1); } diff --git a/src/map/valid_map.c b/src/map/valid_map.c index 10bc7e8..adcc2ed 100755 --- a/src/map/valid_map.c +++ b/src/map/valid_map.c @@ -6,7 +6,7 @@ /* By: aortigos