fix: use same t_map in all code
This commit is contained in:
parent
c9d9faa45c
commit
c9ac445103
16
cube3D.h
16
cube3D.h
@ -6,13 +6,14 @@
|
||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/26 12:34:04 by erey-bet #+# #+# */
|
||||
/* Updated: 2023/04/27 14:41:37 by erey-bet ### ########.fr */
|
||||
/* Updated: 2023/05/05 11:15:42 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CUBE3D_H
|
||||
# define CUBE3D_H
|
||||
|
||||
# include "map/map.h"
|
||||
# include "libftx/libftx.h"
|
||||
# include <sys/types.h>
|
||||
# include "MLX42/include/MLX42/MLX42.h"
|
||||
@ -22,19 +23,6 @@
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
|
||||
// img: 0=Nord, 1=WEST, 2=SUD, 3=EAST;
|
||||
|
||||
typedef struct s_map
|
||||
{
|
||||
char **map;
|
||||
size_t size_x;
|
||||
size_t size_y;
|
||||
void *img[4];
|
||||
long color_bot;
|
||||
long color_top;
|
||||
double ply_x;
|
||||
double ply_y;
|
||||
} t_map;
|
||||
|
||||
/*INIT*/
|
||||
t_map *map_parsing(char *path);
|
||||
|
18
main.c
18
main.c
@ -6,7 +6,7 @@
|
||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/26 12:44:55 by erey-bet #+# #+# */
|
||||
/* Updated: 2023/05/03 12:50:25 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/05/05 11:20:37 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -19,26 +19,12 @@ int main(int argc, char **argv)
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("No argument");
|
||||
ft_eprintf("No argument");
|
||||
return (1);
|
||||
}
|
||||
map = map_parsing(argv[1]);
|
||||
if (!map)
|
||||
return (2);
|
||||
ft_printf("%S", map->map);
|
||||
return (2);
|
||||
(void)argv;
|
||||
map = malloc(sizeof(t_map));
|
||||
map->map = malloc(sizeof(char *) * 5);
|
||||
map->map[0] = "11111";
|
||||
map->map[1] = "10001";
|
||||
map->map[2] = "10S01";
|
||||
map->map[3] = "10101";
|
||||
map->map[4] = "11111";
|
||||
map->size_x = 5;
|
||||
map->size_y = 5;
|
||||
map->ply_x = 3;
|
||||
map->ply_y = 3;
|
||||
if (start_game(map))
|
||||
{
|
||||
return (3);
|
||||
|
@ -10,8 +10,8 @@ typedef struct s_map
|
||||
void *img[4];
|
||||
long long color_bot;
|
||||
long long color_top;
|
||||
long long spawn_x;
|
||||
long long spawn_y;
|
||||
double ply_x;
|
||||
double ply_y;
|
||||
char direction;
|
||||
} t_map;
|
||||
|
||||
|
@ -83,7 +83,7 @@ t_map *map_parsing(const char *path)
|
||||
return (NULL);
|
||||
}
|
||||
map->map = body;
|
||||
map->direction = map->map[map->spawn_y][map->spawn_x];
|
||||
map->map[map->spawn_y][map->spawn_x] = '0';
|
||||
map->direction = map->map[(size_t) map->ply_y][(size_t) map->ply_x];
|
||||
map->map[(size_t) map->ply_y][(size_t) map->ply_x] = '0';
|
||||
return (map);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ char **get_body(const char **file_content, size_t header_size)
|
||||
return (body);
|
||||
}
|
||||
|
||||
int get_spawn_position(const char **body, long long *spawn_x, long long *spawn_y)
|
||||
int get_spawn_position(const char **body, double *spawn_x, double *spawn_y)
|
||||
{
|
||||
size_t x;
|
||||
size_t y;
|
||||
@ -160,7 +160,7 @@ int body_is_valid(const char **body, t_map *map)
|
||||
|
||||
if (body == NULL)
|
||||
return (0);
|
||||
error = get_spawn_position(body, &map->spawn_x, &map->spawn_y);
|
||||
error = get_spawn_position(body, &map->ply_x, &map->ply_y);
|
||||
if (error == 1)
|
||||
{
|
||||
ft_eprintf("map: spawn position: multiple definition");
|
||||
|
Loading…
Reference in New Issue
Block a user