aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_init_sfx.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-13 03:11:12 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-13 03:11:12 +0100
commita90c6f5cafbc47c7380d932d8db7bffd9b8b72bf (patch)
tree4e7044b92a3e97a338aaf769fe2b55d63e69338b /src/ft_init_sfx.c
parentRemoved beta minilibx make options (diff)
download42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.tar.gz
42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.tar.bz2
42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.tar.xz
42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.tar.zst
42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.zip
sounds
Diffstat (limited to '')
-rw-r--r--src/ft_init_sfx.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c
new file mode 100644
index 0000000..1452b5c
--- /dev/null
+++ b/src/ft_init_sfx.c
@@ -0,0 +1,47 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_init_lists.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:28:53 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:28:53 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <mlx.h>
+#include <cub3d.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+static int8_t
+ ft_split_sfx(char ***target, const char *path)
+{
+ uint8_t len;
+ char *tmp;
+
+ len = ft_strlen(path);
+ len += ft_strlen(FT_SND_CMD) - 2;
+ if (!(tmp = (char *)malloc((len + 1) * sizeof(char))))
+ return (-1);
+ ft_sprintf(tmp, FT_SND_CMD, path);
+ if (!(*target = ft_split(tmp, ' ')))
+ {
+ ft_memdel((void**)&tmp);
+ return (-1);
+ }
+ ft_memdel((void**)&tmp);
+ return (0);
+}
+
+int8_t
+ ft_init_sfx(t_sfx *sfx)
+{
+ if (ft_split_sfx(&sfx->death, FT_SFX_DEATH_PATH) < 0 ||
+ ft_split_sfx(&sfx->trap, FT_SFX_TRAP_PATH) < 0)
+ return (-1);
+ return (0);
+}