diff --git a/include/meta.h b/include/meta.h index 6ca484f..0947bc9 100644 --- a/include/meta.h +++ b/include/meta.h @@ -314,7 +314,7 @@ void print_double_array(char *msg, double *arr, uint32_t size, t_sprite *sp, int void print_ints_array(char *msg, int32_t *arr, uint32_t size); void print_sprites_array(t_sprite *arr, uint32_t size); void print_attributes(t_attr *attributes); - +void print_door_data(t_door doors); // sprite_utils.c void sprite_sort(double *sprite_dist, int32_t *sprite_order, uint32_t sprite_count); diff --git a/src/game/player.c b/src/game/player.c index 24db8a7..1126421 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -120,6 +120,4 @@ void player_raycast(t_player *p) } sprite_calculate(p); - - } diff --git a/src/game/render_viewport.c b/src/game/render_viewport.c index 89211d6..85fceab 100644 --- a/src/game/render_viewport.c +++ b/src/game/render_viewport.c @@ -111,6 +111,8 @@ void render_viewport(mlx_image_t *image, t_player *p) draw_column(p->meta, &p->rays[col], col, image->height); col++; } - // render sprites + + // render doors + } diff --git a/src/parser/parse_elements.c b/src/parser/parse_elements.c index 8067a5d..ac68d41 100644 --- a/src/parser/parse_elements.c +++ b/src/parser/parse_elements.c @@ -134,7 +134,7 @@ int input_sprite_texture_path(t_sprite **sprites_array, uint32_t *i ,char *conte int input_door_path(t_door *doors, char *content) { - doors->tex.tex_path = content; + doors->tex.tex_path = ft_strdup(content); return (EXIT_SUCCESS); } diff --git a/src/set_textures.c b/src/set_textures.c index 300ae8b..db89c1b 100644 --- a/src/set_textures.c +++ b/src/set_textures.c @@ -54,6 +54,17 @@ int set_sprite_textures(uint32_t sprite_count, t_sprite *sprites) return (EXIT_SUCCESS); } +int set_door_texture(t_door *doors) +{ + if (doors->door_count) + { + doors->tex.tex = mlx_load_png(doors->tex.tex_path); + if (doors->tex.tex == NULL) + return (EXIT_FAILURE); + } + return (EXIT_SUCCESS); +} + int set_textures(t_attr *attributes) { attributes->n.tex = mlx_load_png(attributes->n.tex_path); @@ -72,6 +83,8 @@ int set_textures(t_attr *attributes) return (pr_err(MLX_ERROR)); if (set_sprite_textures(attributes->sprite_count, attributes->sprites)) return (pr_err(MLX_ERROR)); + if (set_door_texture(&attributes->doors)) + return (pr_err(MLX_ERROR)); return (EXIT_SUCCESS); } diff --git a/src/test_utils.c b/src/test_utils.c index 45be0e1..cfeb8f0 100644 --- a/src/test_utils.c +++ b/src/test_utils.c @@ -135,4 +135,21 @@ void print_attributes(t_attr *attributes) printf("C: %s\n", attributes->c.tex_path); else printf("C: %d,%d,%d\n", attributes->ceiling_c.r, attributes->ceiling_c.g, attributes->ceiling_c.b); +} + +void print_door_data(t_door doors) +{ + int i = 0; + printf("DOOR COUNT: %u\n", doors.door_count); + printf("DOOR TEX: %s\n", doors.tex.tex_path); + while (i < doors.door_count) + { + if (i == 0) + printf("DOOR IDX: "); + printf("%u", doors.idx[i]); + if (i < doors.door_count - 1) + printf(" | "); + i++; + } + printf("\n"); } \ No newline at end of file diff --git a/test_maps/valid_tex.cub b/test_maps/valid_tex.cub index 0a7bcea..e4f01d5 100644 --- a/test_maps/valid_tex.cub +++ b/test_maps/valid_tex.cub @@ -7,14 +7,13 @@ C texture_examples/ceiling_square.png SP texture_examples/pillar.png 4.5 2.5 SP texture_examples/barrel.png 5.5 3.5 -SP texture_examples/hoofd.png 2.5 3.5 -SP texture_examples/sexy.png 2.5 2.5 +DR texture_examples/door.png 11111111111111 1000000001 1000000001 1000000001 -1000000001 +10000000D1 100000000111 111000N00111 100000000001 diff --git a/texture_examples/door.png b/texture_examples/door.png new file mode 100644 index 0000000..22e16e0 Binary files /dev/null and b/texture_examples/door.png differ