Fixes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
NO assets/textures/backRoom3.png
|
||||
SO assets/textures/forest.png
|
||||
WE assets/textures/backRoom3.png
|
||||
@@ -14,59 +16,7 @@ C 255,255,255
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000N00000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
100000000000N0000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
10000000000000000000000000001
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/11/25 19:47:02 by aortigos #+# #+# */
|
||||
/* Updated: 2026/01/25 16:27:23 by aortigos ### ########.fr */
|
||||
/* Updated: 2026/01/25 16:42:38 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
# include "../lib/ft_printf/ft_printf.h"
|
||||
# include "../lib/gnl/get_next_line.h"
|
||||
|
||||
|
||||
# define S_W 1920
|
||||
# define S_H 1080
|
||||
# define WALL_SIZE 64
|
||||
@@ -57,8 +56,8 @@ typedef struct s_tex
|
||||
// of failing. First check, then load as texture.
|
||||
typedef struct s_texture_list
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
char *name;
|
||||
char *value;
|
||||
struct s_texture_list *next;
|
||||
} t_texture_list;
|
||||
|
||||
@@ -90,35 +89,34 @@ typedef struct s_ray
|
||||
// Map data
|
||||
typedef struct s_data
|
||||
{
|
||||
int p_x;
|
||||
int p_y;
|
||||
int w_map;
|
||||
int h_map;
|
||||
int fd;
|
||||
char *line;
|
||||
char *ture;
|
||||
char **texture2d;
|
||||
char *map;
|
||||
char **map2d;
|
||||
char **sq_map;
|
||||
char **cc;
|
||||
char **ff;
|
||||
int p_x;
|
||||
int p_y;
|
||||
int w_map;
|
||||
int h_map;
|
||||
int fd;
|
||||
char *line;
|
||||
char *ture;
|
||||
char **texture2d;
|
||||
char *map;
|
||||
char **map2d;
|
||||
char **sq_map;
|
||||
char **cc;
|
||||
char **ff;
|
||||
t_texture_list *t_list;
|
||||
} t_data;
|
||||
|
||||
// All global data in one unique structure
|
||||
typedef struct s_mlx
|
||||
{
|
||||
mlx_image_t *img;
|
||||
mlx_t *mlx_ptr;
|
||||
t_ray *ray;
|
||||
t_data *dt;
|
||||
t_player *ply;
|
||||
t_tex *tex;
|
||||
mlx_image_t *img;
|
||||
mlx_t *mlx_ptr;
|
||||
t_ray *ray;
|
||||
t_data *dt;
|
||||
t_player *ply;
|
||||
t_tex *tex;
|
||||
t_texture_list *l_ture;
|
||||
} t_mlx;
|
||||
|
||||
|
||||
// Functions
|
||||
// parsing.c
|
||||
int read_map(char *av, t_data *map, int *count);
|
||||
@@ -134,7 +132,7 @@ void freelist(t_texture_list **txture);
|
||||
|
||||
// lst_textures.c
|
||||
int get_index(char *line, int i);
|
||||
t_texture_list *new_texture(char *line);
|
||||
t_texture_list *new_texture(char *line);
|
||||
void lst_back_ture(t_texture_list **l_ture, t_texture_list *new);
|
||||
int lst_ture(t_data *m, t_texture_list **l_ture);
|
||||
|
||||
@@ -170,7 +168,7 @@ char *getlastline(char **map);
|
||||
int h_map(char **map);
|
||||
int v_map(char **map);
|
||||
char *fixline(char *line, int maxlen);
|
||||
int getsize_line(char **map);
|
||||
int getsize_line(char **map);
|
||||
int valid_map(t_data *m);
|
||||
|
||||
// frees.c
|
||||
@@ -185,7 +183,8 @@ void ft_reset_move(mlx_key_data_t keydata, t_mlx *mlx);
|
||||
void key_press(mlx_key_data_t keydata, void *ml);
|
||||
|
||||
// raycasting.c
|
||||
int inter_check(float angle, float *inter, float *step, int is_horizon);
|
||||
int inter_check(float angle, float *inter,
|
||||
float *step, int is_horizon);
|
||||
int wall_hit(float x, float y, t_mlx *mlx);
|
||||
float get_h_inter(t_mlx *mlx, float angl);
|
||||
float get_v_inter(t_mlx *mlx, float angl);
|
||||
@@ -212,6 +211,4 @@ int load_texture(t_tex *tex, t_texture_list *l_ture);
|
||||
void get_angle(t_mlx *mlx);
|
||||
int execution(t_data *dt);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,12 +6,18 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/15 18:37:44 by aortigos #+# #+# */
|
||||
/* Updated: 2026/01/25 16:06:30 by aortigos ### ########.fr */
|
||||
/* Updated: 2026/01/25 16:57:02 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "get_next_line.h"
|
||||
|
||||
static void free_mem(char *left_str, char *buff)
|
||||
{
|
||||
free(left_str);
|
||||
free(buff);
|
||||
}
|
||||
|
||||
char *ft_read_to_left_str(int fd, char *left_str)
|
||||
{
|
||||
char *buff;
|
||||
@@ -27,8 +33,7 @@ char *ft_read_to_left_str(int fd, char *left_str)
|
||||
rd_bytes = read(fd, buff, BUFFER_SIZE);
|
||||
if (rd_bytes == -1)
|
||||
{
|
||||
free(left_str);
|
||||
free(buff);
|
||||
free_mem(left_str, buff);
|
||||
return (NULL);
|
||||
}
|
||||
buff[rd_bytes] = '\0';
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user