aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-14 01:06:59 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-14 01:06:59 +0100
commita383bde7d29293919eb635aeb14760a7a55e12b3 (patch)
tree76000460117d1ab1348d98a03e2c92215755fde8 /src
parentFuck threads and forks (diff)
download42-cub3d-a383bde7d29293919eb635aeb14760a7a55e12b3.tar.gz
42-cub3d-a383bde7d29293919eb635aeb14760a7a55e12b3.tar.bz2
42-cub3d-a383bde7d29293919eb635aeb14760a7a55e12b3.tar.xz
42-cub3d-a383bde7d29293919eb635aeb14760a7a55e12b3.tar.zst
42-cub3d-a383bde7d29293919eb635aeb14760a7a55e12b3.zip
Removed footsteps, in progress
Diffstat (limited to '')
-rw-r--r--src/ft_check_missing.c6
-rw-r--r--src/ft_exit.c3
-rw-r--r--src/ft_init_sfx.c2
-rw-r--r--src/ft_key_loop.c4
-rw-r--r--src/ft_sfx_new_level.c (renamed from src/ft_sfx_footstep.c)22
-rw-r--r--src/ft_suffer_animation.c10
6 files changed, 13 insertions, 34 deletions
diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c
index f9df88f..617e8f5 100644
--- a/src/ft_check_missing.c
+++ b/src/ft_check_missing.c
@@ -29,12 +29,6 @@ static int
if (ft_check_not_found(FT_SFX_DEATH_PATH) < 0 ||
ft_check_ext(FT_SFX_DEATH_PATH, ".wav") < 0)
return (ft_missing_error(FT_ERR_MISS_SFX_DEATH, clist));
- if (ft_check_not_found(FT_SFX_FS_ONE_PATH) < 0 ||
- ft_check_ext(FT_SFX_FS_ONE_PATH, ".wav") < 0)
- return (ft_missing_error(FT_ERR_MISS_SFX_FS_ONE, clist));
- if (ft_check_not_found(FT_SFX_FS_TWO_PATH) < 0 ||
- ft_check_ext(FT_SFX_FS_TWO_PATH, ".wav") < 0)
- return (ft_missing_error(FT_ERR_MISS_SFX_FS_TWO, clist));
if (ft_check_not_found(FT_SFX_N_LVL_PATH) < 0 ||
ft_check_ext(FT_SFX_N_LVL_PATH, ".wav") < 0)
return (ft_missing_error(FT_ERR_MISS_SFX_N_LVL, clist));
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 6a92dac..e7b344e 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -82,9 +82,6 @@ static void
if (!(tmp = waitpid(clist->sfx.death_pid, NULL, WNOHANG)))
kill(clist->sfx.death_pid, SIGTERM);
wait(&clist->sfx.death_pid);
- if (!(tmp = waitpid(clist->sfx.footstep_pid, NULL, WNOHANG)))
- kill(clist->sfx.footstep_pid, SIGTERM);
- wait(&clist->sfx.footstep_pid);
if (!(tmp = waitpid(clist->sfx.new_lvl_pid, NULL, WNOHANG)))
kill(clist->sfx.new_lvl_pid, SIGTERM);
wait(&clist->sfx.new_lvl_pid);
diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c
index 84032d7..728e410 100644
--- a/src/ft_init_sfx.c
+++ b/src/ft_init_sfx.c
@@ -42,8 +42,6 @@ int8_t
ft_init_sfx(t_sfx *sfx)
{
if (ft_split_sfx(&sfx->death, FT_SFX_DEATH_PATH) < 0 ||
- ft_split_sfx(&sfx->footstep_one, FT_SFX_FS_ONE_PATH) < 0 ||
- ft_split_sfx(&sfx->footstep_two, FT_SFX_FS_TWO_PATH) < 0 ||
ft_split_sfx(&sfx->new_lvl, FT_SFX_N_LVL_PATH) < 0 ||
ft_split_sfx(&sfx->pain_one, FT_SFX_SCR_ONE_PATH) < 0 ||
ft_split_sfx(&sfx->pain_two, FT_SFX_SCR_TWO_PATH) < 0 ||
diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c
index 647b887..dc3a65d 100644
--- a/src/ft_key_loop.c
+++ b/src/ft_key_loop.c
@@ -83,19 +83,19 @@ int
{
cl->key_ptr[cl->key_input[i]](cl);
ft_collision(old_y, old_x, cl->key_input[i], cl);
- if (cl->key_input[i] >= 0 && cl->key_input[i] <= 3)
- ft_sfx_footstep(cl);
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)
{
+ ft_sfx_new_level(cl);
return ((ft_warp_level(cl->mlist.nlevel_path, cl) < 0) ?
(ft_exit(FT_RET_FAILED_STRUCTS, cl)) : (0));
}
}
i++;
}
+ ft_printf("%hhu\n", cl->plist.isdead);
if (cl->key_input[0] != -1)
ft_draw_scene(cl);
return (0);
diff --git a/src/ft_sfx_footstep.c b/src/ft_sfx_new_level.c
index e629a7b..05e9059 100644
--- a/src/ft_sfx_footstep.c
+++ b/src/ft_sfx_new_level.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_sfx_trap.c :+: :+: :+: */
+/* ft_sfx_new_level.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -12,25 +12,13 @@
#include <cub3d.h>
#include <unistd.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
void
- ft_sfx_footstep(t_cub *cl)
+ ft_sfx_new_level(t_cub *cl)
{
- static uint8_t ref = 0;
-
- cl->sfx.footstep_pid = fork();
- if (cl->sfx.footstep_pid == 0)
+ cl->sfx.new_lvl_pid = fork();
+ if (cl->sfx.new_lvl_pid == 0)
{
- ref = (ref > 201) ? (0) : (ref + 1);
- if (ref % 2)
- execve(*(cl->sfx.footstep_one + 0),
- cl->sfx.footstep_one, cl->envp);
- else
- execve(*(cl->sfx.footstep_two + 0),
- cl->sfx.footstep_two, cl->envp);
+ execve(*(cl->sfx.new_lvl + 0), cl->sfx.new_lvl, cl->envp);
}
}
diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c
index 651f4dd..6933f56 100644
--- a/src/ft_suffer_animation.c
+++ b/src/ft_suffer_animation.c
@@ -31,10 +31,8 @@ void
{
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);
@@ -47,7 +45,8 @@ void
ft_sfx_death(cl);
/* TODO death screen here */
}
- ft_sfx_trap(cl);
+ else
+ ft_sfx_trap(cl);
}
void
@@ -77,7 +76,10 @@ void
{
cl->plist.isdead = 1;
ft_warp_level(cl->mlist.filename, cl);
+ ft_sfx_death(cl);
+ /* TODO death screen here */
}
- /* TODO death screen here */
+ else
+ ft_sfx_trap(cl);
cl->doicast = 0;
}