diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 diff --git a/assets/maps/map.cub b/assets/maps/map.cub old mode 100644 new mode 100755 index d5dfcbb..88c7da2 --- a/assets/maps/map.cub +++ b/assets/maps/map.cub @@ -1,14 +1,14 @@ -NO assets/textures/backRoom3.png -SO assets/textures/backRoom3.png -WE assets/textures/backRoom3.png -EA assets/textures/backRoom3.png +NO assets/textures/forest.png +SO assets/textures/forest.png +WE assets/textures/forest.png +EA assets/textures/forest.png C 164,157,79 F 30,55,55 -11111111111111111111111111111 -10000000001100000000000000001 -10110000011100000010000010001 +11111111111111111111111111111 111 +10000000001100000000000000001 101 +10110000011100000010000010001 111 10010000000000000000000010001 10110000011100000010000010001 10000000001100000111011110001 diff --git a/assets/maps/map2.cub b/assets/maps/map2.cub old mode 100644 new mode 100755 index cdb1b1d..0cd443c --- a/assets/maps/map2.cub +++ b/assets/maps/map2.cub @@ -1,15 +1,15 @@ NO assets/textures/backRoom3.png SO assets/textures/backRoom3.png WE assets/textures/backRoom3.png -EAS assets/textures/backRoom3.png +EA assets/textures/backRoom3.png C 164,157,79 F 30,55,55 - 11111111111111111111111111 + 111111111111111111111111111 100000000011100000000000001 - 10110000011 110000000000001 - 100100000001000000N0000011 + 10110000011 110000000000N01 + 10010000000100000000000011 111111111011000001110000000000001 100000000011000001110111110111111 11110111111111011100000010001 diff --git a/assets/textures/backRoom3.png b/assets/textures/backRoom3.png old mode 100644 new mode 100755 diff --git a/assets/textures/forest.png b/assets/textures/forest.png new file mode 100644 index 0000000..1a140fc Binary files /dev/null and b/assets/textures/forest.png differ diff --git a/assets/textures/hola.png b/assets/textures/hola.png new file mode 100755 index 0000000..e2c9bcd Binary files /dev/null and b/assets/textures/hola.png differ diff --git a/includes/cub3d.h b/includes/cub3d.h old mode 100644 new mode 100755 index 615c05a..421db64 --- a/includes/cub3d.h +++ b/includes/cub3d.h @@ -6,7 +6,7 @@ /* By: aortigos 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) diff --git a/src/execution/raycasting.c b/src/execution/raycasting.c old mode 100644 new mode 100755 index dad1090..a722503 --- a/src/execution/raycasting.c +++ b/src/execution/raycasting.c @@ -6,7 +6,7 @@ /* By: aortigos 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); } diff --git a/src/execution/render2.c b/src/execution/render2.c old mode 100644 new mode 100755 diff --git a/src/free/clean.c b/src/free/clean.c old mode 100644 new mode 100755 diff --git a/src/free/frees.c b/src/free/frees.c old mode 100644 new mode 100755 diff --git a/src/main.c b/src/main.c old mode 100644 new mode 100755 diff --git a/src/map/read_map.c b/src/map/read_map.c old mode 100644 new mode 100755 index 5aa839c..ba25e10 --- a/src/map/read_map.c +++ b/src/map/read_map.c @@ -6,7 +6,7 @@ /* By: aortigos ture, map->line, map->fd); exit(1); } diff --git a/src/map/read_map_utils.c b/src/map/read_map_utils.c old mode 100644 new mode 100755 index faf4528..42f293a --- a/src/map/read_map_utils.c +++ b/src/map/read_map_utils.c @@ -6,7 +6,7 @@ /* By: aortigos 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); diff --git a/src/map/valid_map.c b/src/map/valid_map.c old mode 100644 new mode 100755 diff --git a/src/parsing/lst_textures.c b/src/parsing/lst_textures.c old mode 100644 new mode 100755 diff --git a/src/parsing/parsing.c b/src/parsing/parsing.c old mode 100644 new mode 100755 diff --git a/src/parsing/textures.c b/src/parsing/textures.c old mode 100644 new mode 100755 diff --git a/src/parsing/textures_utils.c b/src/parsing/textures_utils.c old mode 100644 new mode 100755