diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_check_missing.c | 2 | ||||
-rw-r--r-- | src/ft_del_extra_sprites.c | 31 | ||||
-rw-r--r-- | src/ft_exit.c | 1 | ||||
-rw-r--r-- | src/ft_key_loop.c | 5 | ||||
-rw-r--r-- | src/ft_suffer_animation.c | 31 | ||||
-rw-r--r-- | src/ft_treat_args.c | 2 | ||||
-rw-r--r-- | src/ft_warp_level.c | 4 |
7 files changed, 69 insertions, 7 deletions
diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c index e349d05..1e89781 100644 --- a/src/ft_check_missing.c +++ b/src/ft_check_missing.c @@ -27,7 +27,7 @@ static int ft_check_missing_sfx(t_cub *clist) { if (ft_check_not_found(FT_SFX_DEATH_PATH) < 0) - return (ft_missing_error(FT_MISS_SFX_DEATH, clist)); + return (ft_missing_error(FT_ERR_MISS_SFX_DEATH, clist)); if (ft_check_not_found(FT_SFX_FS_ONE_PATH) < 0) return (ft_missing_error(FT_ERR_MISS_SFX_FS_ONE, clist)); if (ft_check_not_found(FT_SFX_FS_TWO_PATH) < 0) diff --git a/src/ft_del_extra_sprites.c b/src/ft_del_extra_sprites.c new file mode 100644 index 0000000..21df608 --- /dev/null +++ b/src/ft_del_extra_sprites.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_key_loop.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/17 20:06:26 by rbousset #+# #+# */ +/* Updated: 2020/02/17 20:06:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> +#include <mlx.h> +#include <stdint.h> +#include <stddef.h> + +void + ft_del_extra_sprites(t_cub *cl) +{ + uint8_t i; + + i = 1; + while ((i + 2) <= cl->mlist.topsp) + { + if (cl->tlist[i + 7].img) + mlx_destroy_image(cl->wlist.wlx, cl->tlist[i + 7].img); + i++; + } +} diff --git a/src/ft_exit.c b/src/ft_exit.c index 3ec26ad..28a1489 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -71,6 +71,7 @@ int { if (clist->walltexgood) ft_del_tex(clist); + ft_del_extra_sprites(clist); if (clist->wlist.inited) { if (FT_OS == 1) diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c index 66f72ef..8f9d688 100644 --- a/src/ft_key_loop.c +++ b/src/ft_key_loop.c @@ -58,7 +58,10 @@ static void { pl->pos_x = old_x + ((old_x - x) / 3); pl->pos_y = old_y + ((old_y - y) / 3); - ft_suffer_animation(cl); + 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); } diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index bc8eb12..7df91cd 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -17,7 +17,36 @@ #include <unistd.h> void - ft_suffer_animation(t_cub *cl) + ft_linux_suffer_animation(t_cub *cl) +{ + int32_t x; + int32_t y; + + y = -1; + cl->img.img = mlx_new_image(cl->wlist.wlx, + cl->wlist.x_size, cl->wlist.y_size); + cl->img.ptr = mlx_get_data_addr(cl->img.img, &cl->img.bpp, + &cl->img.sizeline, &cl->img.endian); + while (++y < (int32_t)cl->wlist.y_size) + { + x = -1; + while (++x < (int32_t)cl->wlist.x_size) + { + *(int*)(cl->img.ptr + + (x * 4 + (y * cl->img.sizeline))) = 0x00880404; + } + } + mlx_put_image_to_window(cl->wlist.wlx, + cl->wlist.winptr, cl->img.img, 0, 0); + mlx_destroy_image(cl->wlist.wlx, cl->img.img); + cl->plist.life -= 20; + if (cl->plist.life <= 0) + ft_warp_level(cl->mlist.filename, cl); + /* TODO death screen here */ +} + +void + ft_macos_suffer_animation(t_cub *cl) { int32_t x; int32_t y; diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c index 92464ab..4cc759e 100644 --- a/src/ft_treat_args.c +++ b/src/ft_treat_args.c @@ -55,6 +55,6 @@ uint8_t return (ft_exit(FT_RET_FINE, clist)); } else - return (ft_error(FT_RET_BAD_ARGV, FT_ERR_ARGV, clist)) + return (ft_error(FT_RET_BAD_ARGV, FT_ERR_ARGV, clist)); return (FT_RET_FINE); } diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 7a04dc9..69b7b78 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -58,16 +58,14 @@ static void cl->tlist[i].img = NULL; } if (cl->mlist.isnlvl && cl->tlist[5].img) - { mlx_destroy_image(cl->wlist.wlx, cl->tlist[5].img); - cl->tlist[5].img = NULL; - } 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); } static void |