Skip to content

Commit

Permalink
have not finished adding doors
Browse files Browse the repository at this point in the history
  • Loading branch information
Yesim Zaim committed Feb 7, 2024
1 parent ae3c212 commit 99e0d22
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 110 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ IFLAGS := -Ilibft/include -Iinclude -IMLX42/include
SRC_DIR := src

SRCS = parser/check_elements.c \
parser/check_walls.c \
parser/parse_elements.c \
parser/parse_map.c \
parser/check_map.c \
Expand Down
7 changes: 7 additions & 0 deletions include/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ typedef struct s_sprite {
t_tex tex;
} t_sprite;

typedef struct s_door {
t_tex tex;
uint32_t idx;
}

typedef struct s_attr {
t_tex n; //add bit flag, if tex_path is missing then it means it is a color value
t_tex s;
Expand All @@ -219,6 +224,8 @@ typedef struct s_attr {
uint32_t sprite_count;
uint32_t sprite_arr_index;
t_sprite *sprites; // we need to make the sprite count modular
uint32_t door_count;
t_door *doors;
} t_attr;

typedef struct s_minimap {
Expand Down
3 changes: 3 additions & 0 deletions src/parser/check_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ t_cell_type find_enum_value(char c)
{
return (MAP_WALL);
}
else if (c == 'D')
return (MAP_DOOR);
else
{
return (MAP_SPACE);
Expand All @@ -135,6 +137,7 @@ bool save_map(t_meta *meta, char *rect)
}
return (true);
}

int check_map(t_meta *meta, char *rect)
{
if (!is_map_chars_valid(rect))
Expand Down
108 changes: 0 additions & 108 deletions src/parser/check_walls.c

This file was deleted.

36 changes: 36 additions & 0 deletions src/parser/parse_elements.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,48 @@ int set_up_sprites(t_meta *meta)
return (EXIT_SUCCESS);
}

uint32_t count_doors(t_cell_type *map, uint32_t w, uint32_t h)
{
uint32_t doors;
uint32_t i;

doors = 0;
i = 0;
while (i < w * h)
{
if (map[i] == MAP_DOOR)
doors++;
i++;
}
return (doors);
}

int save_index(t_door *doors, uint32_t door_count)
{
uint32_t i;

i = 0;
}

int set_doors(t_meta *meta)
{
meta.attributes.doors = malloc(sizeof(t_door) * meta.attributes.door_count);
if (!meta.attributes.doors)
return (pr_err(MALL_ERR));

}

int parse_elements(t_meta *meta)
{
t_flag *elements = meta->elements;
meta->attributes.sprite_count = count_sprites(meta->elements);
meta.attributes.door_count = count_doors(meta.map.level, meta.map.width, meta.map.height);
meta->attributes.sprite_arr_index = 0;

if (meta.attributes.door_count)
{
// save door idx
}
if (set_up_sprites(meta))
return (EXIT_FAILURE);
while (elements != NULL)
Expand Down
2 changes: 1 addition & 1 deletion src/parser/utils_one.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void skip_digits(char **file)
int valid_map_char(char c)
{
return (c == '1' || c == '0' || c == 'N' || c == 'S' \
|| c == 'E' || c == 'W' || c == ' ');
|| c == 'E' || c == 'W' || c == ' ' || c == 'D');
}

int player_pos_char(char c)
Expand Down

0 comments on commit 99e0d22

Please sign in to comment.