Wall orientation and see through wall
This commit is contained in:
0
src/execution/execution.c
Normal file → Executable file
0
src/execution/execution.c
Normal file → Executable file
35
src/execution/movement.c
Normal file → Executable file
35
src/execution/movement.c
Normal file → Executable file
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/12/05 17:11:09 by aortigos #+# #+# */
|
||||
/* Updated: 2025/12/09 18:40:05 by aortigos ### ########.fr */
|
||||
/* Updated: 2026/01/25 15:45:28 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -30,25 +30,30 @@ void rotate_player(t_mlx *mlx, int i)
|
||||
|
||||
void move_player(t_mlx *mlx, double move_x, double move_y)
|
||||
{
|
||||
int map_grid_y;
|
||||
int map_grid_x;
|
||||
int new_x;
|
||||
int new_y;
|
||||
double new_x;
|
||||
double new_y;
|
||||
int grid_x;
|
||||
int grid_y;
|
||||
|
||||
new_x = roundf(mlx->ply->plyr_x + move_x);
|
||||
new_y = roundf(mlx->ply->plyr_y + move_y);
|
||||
map_grid_x = (new_x / WALL_SIZE);
|
||||
map_grid_y = (new_y / WALL_SIZE);
|
||||
if (mlx->dt->sq_map[map_grid_y][map_grid_x] != '1'
|
||||
&& (mlx->dt->sq_map[map_grid_y][mlx->ply->plyr_x / WALL_SIZE] != '1'
|
||||
&& mlx->dt->sq_map[mlx->ply->plyr_y
|
||||
/ WALL_SIZE][map_grid_x] != '1'))
|
||||
{
|
||||
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)
|
||||
|
||||
2
src/execution/raycasting.c
Normal file → Executable file
2
src/execution/raycasting.c
Normal file → Executable file
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/12/09 18:41:15 by aortigos #+# #+# */
|
||||
/* Updated: 2025/12/09 18:41:30 by aortigos ### ########.fr */
|
||||
/* Updated: 2026/01/25 15:41:07 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
14
src/execution/render.c
Normal file → Executable file
14
src/execution/render.c
Normal file → Executable file
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/12/09 18:42:30 by aortigos #+# #+# */
|
||||
/* Updated: 2025/12/11 20:02:51 by aortigos ### ########.fr */
|
||||
/* Updated: 2026/01/25 15:29:56 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -53,11 +53,23 @@ double get_x_o(mlx_texture_t *texture, t_mlx *mlx)
|
||||
double x_o;
|
||||
|
||||
if (mlx->ray->flag == 1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
x_o = texture->width - x_o - 1;
|
||||
}
|
||||
|
||||
return (x_o);
|
||||
}
|
||||
|
||||
|
||||
0
src/execution/render2.c
Normal file → Executable file
0
src/execution/render2.c
Normal file → Executable file
0
src/free/clean.c
Normal file → Executable file
0
src/free/clean.c
Normal file → Executable file
0
src/free/frees.c
Normal file → Executable file
0
src/free/frees.c
Normal file → Executable file
0
src/main.c
Normal file → Executable file
0
src/main.c
Normal file → Executable file
4
src/map/read_map.c
Normal file → Executable file
4
src/map/read_map.c
Normal file → Executable file
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/12/04 09:28:05 by aortigos #+# #+# */
|
||||
/* Updated: 2026/01/25 11:02:56 by aortigos ### ########.fr */
|
||||
/* Updated: 2026/01/25 15:49:07 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -92,7 +92,7 @@ void process_map(t_data *map, int *count)
|
||||
(*count)++;
|
||||
} else if (res == -1)
|
||||
{
|
||||
ft_putstr_fd("Error: Invalid element in map\n", 2);
|
||||
ft_putstr_fd(ERR_INV_COP, 2);
|
||||
freetl(map->ture, map->line, map->fd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
4
src/map/read_map_utils.c
Normal file → Executable file
4
src/map/read_map_utils.c
Normal file → Executable file
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/12/04 10:07:52 by aortigos #+# #+# */
|
||||
/* Updated: 2025/12/15 10:27:21 by aortigos ### ########.fr */
|
||||
/* Updated: 2026/01/25 15:49:22 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -82,7 +82,7 @@ int surrounded_by_one(char **map)
|
||||
i = -1;
|
||||
while (map[++i])
|
||||
if (!is_surrounded(map[i]) || !is_validmap(map[i], &flag) || flag > 1)
|
||||
return (ft_putstr_fd("one X\n", 2), 0);
|
||||
return (ft_putstr_fd("Invalid map\n", 2), 0);
|
||||
if (flag == 0)
|
||||
return (ft_putstr_fd("no position map\n", 2), 0);
|
||||
return (1);
|
||||
|
||||
0
src/map/valid_map.c
Normal file → Executable file
0
src/map/valid_map.c
Normal file → Executable file
0
src/parsing/lst_textures.c
Normal file → Executable file
0
src/parsing/lst_textures.c
Normal file → Executable file
0
src/parsing/parsing.c
Normal file → Executable file
0
src/parsing/parsing.c
Normal file → Executable file
0
src/parsing/textures.c
Normal file → Executable file
0
src/parsing/textures.c
Normal file → Executable file
0
src/parsing/textures_utils.c
Normal file → Executable file
0
src/parsing/textures_utils.c
Normal file → Executable file
Reference in New Issue
Block a user