diff options
Diffstat (limited to '')
-rw-r--r-- | inc/cub3d.h | 1 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 1 | ||||
-rw-r--r-- | src/ft_init_lists.c | 3 | ||||
-rw-r--r-- | src/ft_parse_map.c | 6 | ||||
-rw-r--r-- | src/ft_warp_level.c | 19 |
5 files changed, 28 insertions, 2 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h index 4f28a84..f534fe8 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -85,5 +85,6 @@ void ft_draw_life_bar(size_t map_w, void ft_music(t_cub *cl); void ft_draw_sprite(t_cub *cl, int i); int8_t ft_warp_level(t_cub *cl); +t_rgb ft_init_rgb(void); # endif diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 0ed8e63..26e7455 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -131,6 +131,7 @@ typedef struct s_cub { uint8_t w_side; uint8_t ishud; + uint16_t currlvl; char errmsg[40]; int32_t key_input[5]; int (*key_ptr[6])(struct s_cub*); diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index 5592358..f451220 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -18,7 +18,7 @@ #include <limits.h> #include <math.h> -static t_rgb +t_rgb ft_init_rgb(void) { t_rgb rgb; @@ -85,6 +85,7 @@ static t_cub clist->f_rgb = ft_init_rgb(); clist->c_rgb = ft_init_rgb(); clist->rlist = ft_init_s_ray(); + clist->currlvl = 0; clist->key_ptr[0] = ft_w_key; clist->key_ptr[1] = ft_a_key; clist->key_ptr[2] = ft_s_key; diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 400bdd4..afb1d88 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -100,6 +100,10 @@ void ft_get_player_spawn(clist->plist, clist); ft_get_nlvl_pos(clist->mlist); ft_check_missing(clist); - ft_set_minimap_scale(clist); + if (clist->currlvl == 0) + { + ft_set_minimap_scale(clist); + clist->currlvl += 1; + } close(fd); } diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 03302bd..8739550 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -18,6 +18,24 @@ static void ft_memdel((void**)&ml); } +static void + ft_del_some(t_cub *cl) +{ + cl->plist->pos_x = 0; + cl->plist->pos_y = 0; + cl->wlist->x_size = 0; + cl->wlist->y_size = 0; + cl->f_rgb = ft_init_rgb(); + cl->c_rgb = ft_init_rgb(); + cl->plist->start_x = 0; + cl->plist->start_y = 0; + cl->plist->cam_x = 0; + cl->plist->dir_x = -1; + cl->plist->dir_y = 0; + cl->plist->plane_x = 0; + cl->plist->plane_y = 0.66666666; +} + int8_t ft_warp_level(t_cub *cl) { @@ -31,6 +49,7 @@ int8_t return (-1); ft_sprintf(next_path, "%s", cl->mlist->nlevel_path); ft_del_map(cl->mlist); + ft_del_some(cl); if (!(cl->mlist = ft_init_map())) return (-1); ft_parse_map(next_path, cl); |