aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_sfx_footstep.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-13 18:09:55 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-13 18:09:55 +0100
commit273459283c98b5f10814fdf74c74c2e6a13f10c0 (patch)
tree6959619028e32cb5452e7ca6b65cccf5a7ca0072 /src/ft_sfx_footstep.c
parentNew sfx, clean exit (diff)
download42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.tar.gz
42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.tar.bz2
42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.tar.xz
42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.tar.zst
42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.zip
Not ideal
Diffstat (limited to 'src/ft_sfx_footstep.c')
-rw-r--r--src/ft_sfx_footstep.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/ft_sfx_footstep.c b/src/ft_sfx_footstep.c
new file mode 100644
index 0000000..d7a62d2
--- /dev/null
+++ b/src/ft_sfx_footstep.c
@@ -0,0 +1,46 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_sfx_trap.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/24 17:17:54 by rbousset #+# #+# */
+/* Updated: 2020/02/24 17:17:56 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <cub3d.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <libft.h>
+void
+ ft_sfx_footstep(t_cub *cl)
+{
+ static uint8_t ref = 0;
+ pid_t tmp;
+ int status;
+
+ tmp = waitpid(cl->sfx.footstep_pid, &status, WNOHANG);
+ /* ft_printf("top_pid %d\nfs_pid %d\ntmp %d\n\n", getpid(), cl->sfx.footstep_pid, tmp); */
+ if (tmp > 0)
+ {
+ cl->sfx.footstep_pid = fork();
+ if (cl->sfx.footstep_pid == 0)
+ {
+ ref += 1;
+ if (ref > 201)
+ ref = 0;
+ 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);
+ }
+ }
+}