This commit is contained in:
Angel Ortigosa Perez
2026-01-25 16:57:20 +01:00
parent 16b935470a
commit 8a56a115e7
7 changed files with 44 additions and 36263 deletions

View File

@@ -6,7 +6,7 @@
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/05 17:11:09 by aortigos #+# #+# */
/* Updated: 2026/01/25 15:45:28 by aortigos ### ########.fr */
/* Updated: 2026/01/25 16:44:09 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
@@ -37,23 +37,16 @@ void move_player(t_mlx *mlx, double move_x, double move_y)
new_x = mlx->ply->plyr_x + move_x;
new_y = mlx->ply->plyr_y + move_y;
/* X axis */
grid_x = (int)((new_x + copysign(COLLISION_MARGIN, move_x)) / WALL_SIZE);
grid_y = (int)(mlx->ply->plyr_y / WALL_SIZE);
if (mlx->dt->sq_map[grid_y][grid_x] != '1')
mlx->ply->plyr_x = new_x;
/* Y axis */
grid_x = (int)(mlx->ply->plyr_x / WALL_SIZE);
grid_y = (int)((new_y + copysign(COLLISION_MARGIN, move_y)) / WALL_SIZE);
if (mlx->dt->sq_map[grid_y][grid_x] != '1')
mlx->ply->plyr_y = new_y;
}
void cub_hook(t_mlx *mlx, double move_x, double move_y)
{
if (mlx->ply->rot == 1)

View File

@@ -6,7 +6,7 @@
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/09 18:42:30 by aortigos #+# #+# */
/* Updated: 2026/01/25 15:29:56 by aortigos ### ########.fr */
/* Updated: 2026/01/25 16:43:48 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
@@ -56,7 +56,6 @@ double get_x_o(mlx_texture_t *texture, t_mlx *mlx)
{
x_o = (int)fmodf((mlx->ray->horiz_x * (texture->width / WALL_SIZE)),
texture->width);
// Lets invert south wall so we can read text
if (mlx->ray->ray_ngl > 0 && mlx->ray->ray_ngl < M_PI)
x_o = texture->width - x_o - 1;
}
@@ -64,12 +63,10 @@ double get_x_o(mlx_texture_t *texture, t_mlx *mlx)
{
x_o = (int)fmodf((mlx->ray->vert_y * (texture->width / WALL_SIZE)),
texture->width);
// Invert also east wall
if (mlx->ray->ray_ngl > M_PI / 2
&& mlx->ray->ray_ngl < 3 * M_PI / 2)
&& mlx->ray->ray_ngl < 3 * M_PI / 2)
x_o = texture->width - x_o - 1;
}
return (x_o);
}

View File

@@ -6,7 +6,7 @@
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/04 09:28:05 by aortigos #+# #+# */
/* Updated: 2026/01/25 16:09:18 by aortigos ### ########.fr */
/* Updated: 2026/01/25 16:43:09 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
@@ -90,12 +90,13 @@ void process_map(t_data *map, int *count)
map->ture = ft_strdup(tmp);
ft_memfree(tmp);
(*count)++;
} else if (res == -1)
}
else if (res == -1)
{
get_next_line(-1);
ft_putstr_fd(ERR_INV_COP, 2);
freetl(map->ture, map->line, map->fd);
exit(1);
exit(1);
}
ft_memfree(map->line);
map->line = get_next_line(map->fd);