diff options
Diffstat (limited to '')
-rw-r--r-- | inc/cub3d_structs.h | 1 | ||||
-rw-r--r-- | src/ft_init_lists.c | 3 | ||||
-rw-r--r-- | src/ft_key_loop.c | 22 | ||||
-rw-r--r-- | src/ft_parse_map.c | 3 | ||||
-rw-r--r-- | src/ft_suffer_animation.c | 3 | ||||
-rw-r--r-- | src/ft_warp_level.c | 8 |
6 files changed, 18 insertions, 22 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index b28c5ec..543c5a3 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -133,6 +133,7 @@ typedef struct s_player float plane_x; float plane_y; int8_t life; + uint8_t isdead; } t_player; typedef struct s_ray diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index a6484c2..af79b45 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -80,8 +80,7 @@ static int8_t cl->rlist = ft_init_s_ray(); if (ft_init_sfx(&cl->sfx) < 0) return (-1); - ft_printf("%s\n", cl->sfx.death[0]); - ft_printf("%s\n", cl->sfx.trap[0]); + cl->plist.isdead = 0; cl->currlvl = 0; cl->walltexgood = 0; ft_init_funptr(cl); diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c index 8f9d688..a7af38e 100644 --- a/src/ft_key_loop.c +++ b/src/ft_key_loop.c @@ -49,28 +49,26 @@ static void { uint64_t x; uint64_t y; - t_player *pl; - pl = &cl->plist; - x = ft_find_x(key, pl); - y = ft_find_y(key, pl); + x = ft_find_x(key, &cl->plist); + y = ft_find_y(key, &cl->plist); if (cl->mlist.map[y][x] == 'T') { - pl->pos_x = old_x + ((old_x - x) / 3); - pl->pos_y = old_y + ((old_y - y) / 3); + cl->plist.pos_x = old_x + ((old_x - x) / 2); + cl->plist.pos_y = old_y + ((old_y - y) / 2); if (FT_OS == 1) ft_macos_suffer_animation(cl); else ft_linux_suffer_animation(cl); - x = ft_find_x(key, pl); - y = ft_find_y(key, pl); + x = ft_find_x(key, &cl->plist); + y = ft_find_y(key, &cl->plist); } if (ft_ischarset(FT_CHRST_COLLISION, cl->mlist.map[(uint64_t)old_y][x]) || cl->mlist.map[(uint64_t)old_y][x] == '\0') - pl->pos_x = old_x; + cl->plist.pos_x = old_x; if (ft_ischarset(FT_CHRST_COLLISION, cl->mlist.map[y][(uint64_t)old_x]) || cl->mlist.map[y][(uint64_t)old_x] == '\0') - pl->pos_y = old_y; + cl->plist.pos_y = old_y; } int @@ -85,7 +83,7 @@ int { cl->key_ptr[cl->key_input[i]](cl); ft_collision(old_y, old_x, cl->key_input[i], cl); - if (cl->mlist.isnlvl) + if (cl->mlist.isnlvl && !cl->plist.isdead) { if ((uint32_t)cl->plist.pos_x == cl->mlist.nlx && (uint32_t)cl->plist.pos_y == cl->mlist.nly) @@ -96,7 +94,7 @@ int } i++; } - if (cl->key_input[0] != -1) + /* if (cl->key_input[0] != -1) */ ft_draw_scene(cl); return (0); } diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index f1df73d..c5df30e 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -109,6 +109,7 @@ void ft_get_nlvl_pos(&clist->mlist); ft_check_missing(clist); ft_set_minimap_scale(clist); - clist->currlvl += 1; + if (!clist->plist.isdead) + clist->currlvl += 1; close(fd); } diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index 7df91cd..c0bc307 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -41,7 +41,10 @@ void mlx_destroy_image(cl->wlist.wlx, cl->img.img); cl->plist.life -= 20; if (cl->plist.life <= 0) + { + cl->plist.isdead = 1; ft_warp_level(cl->mlist.filename, cl); + } /* TODO death screen here */ } diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 69b7b78..6f1d387 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -52,17 +52,11 @@ static void cl->c_rgb = ft_init_rgb(); cl->rlist = ft_init_s_ray(); i = -1; - while (++i < 5) + while (++i < 8) { mlx_destroy_image(cl->wlist.wlx, cl->tlist[i].img); cl->tlist[i].img = NULL; } - if (cl->mlist.isnlvl && cl->tlist[5].img) - mlx_destroy_image(cl->wlist.wlx, cl->tlist[5].img); - if (cl->mlist.isftex && cl->tlist[6].img) - mlx_destroy_image(cl->wlist.wlx, cl->tlist[6].img); - if (cl->mlist.isctex && cl->tlist[7].img) - mlx_destroy_image(cl->wlist.wlx, cl->tlist[7].img); if (cl->mlist.istraps && cl->tlist[15].img) mlx_destroy_image(cl->wlist.wlx, cl->tlist[15].img); ft_del_extra_sprites(cl); |