diff --git a/cube3D.h b/cube3D.h index f55884f..f08b18a 100644 --- a/cube3D.h +++ b/cube3D.h @@ -6,13 +6,14 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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 # include "MLX42/include/MLX42/MLX42.h" @@ -22,19 +23,6 @@ # include # include -// 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); diff --git a/main.c b/main.c index a72a1c2..802e3f4 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); diff --git a/map/map.h b/map/map.h index bed3d5f..fb207f4 100644 --- a/map/map.h +++ b/map/map.h @@ -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; diff --git a/map/parsing.c b/map/parsing.c index fdea169..0630f88 100644 --- a/map/parsing.c +++ b/map/parsing.c @@ -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); } diff --git a/map/parsing_body.c b/map/parsing_body.c index 9dec019..5451179 100644 --- a/map/parsing_body.c +++ b/map/parsing_body.c @@ -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");