aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_get_weapon_spawn.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-19 14:14:46 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-19 14:14:46 +0100
commit81a32dd145c3cb55b456ba6666de6c80ff5ac92c (patch)
tree505d3ef8352c555883eb94160507ccf5baed3860 /src/ft_get_weapon_spawn.c
parentOkok (diff)
download42-cub3d-81a32dd145c3cb55b456ba6666de6c80ff5ac92c.tar.gz
42-cub3d-81a32dd145c3cb55b456ba6666de6c80ff5ac92c.tar.bz2
42-cub3d-81a32dd145c3cb55b456ba6666de6c80ff5ac92c.tar.xz
42-cub3d-81a32dd145c3cb55b456ba6666de6c80ff5ac92c.tar.zst
42-cub3d-81a32dd145c3cb55b456ba6666de6c80ff5ac92c.zip
Parsed weapons spawns
Diffstat (limited to '')
-rw-r--r--src/ft_get_weapon_spawn.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/ft_get_weapon_spawn.c b/src/ft_get_weapon_spawn.c
new file mode 100644
index 0000000..d9b7d52
--- /dev/null
+++ b/src/ft_get_weapon_spawn.c
@@ -0,0 +1,49 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_get_weapon_spawn.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/28 20:54:28 by rbousset #+# #+# */
+/* Updated: 2020/02/28 20:54:29 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <stdint.h>
+
+static void
+ ft_get_weapon_id_spawn(uint8_t id, size_t y, size_t x, t_cub *clist)
+{
+ clist->mlist.weaps_nbr[id]++;
+ if (clist->mlist.weaps_nbr[id] > 1)
+ ft_map_error(FT_ERR_TOO_MUCH_W_ONE, clist);
+ clist->weaps[id][0].s_pos_x = x;
+ clist->weaps[id][0].s_pos_y = y;
+}
+
+void
+ ft_get_weapon_spawn(t_cub *clist)
+{
+ size_t x;
+ size_t y;
+
+ x = 1;
+ y = 1;
+ i = 0;
+ while (clist->mlist.map[y])
+ {
+ while (clist->mlist.map[y][x])
+ {
+ if (clist->mlist.map[y][x] == '!')
+ ft_get_weapon_one_spawn(0, y, x, clist);
+ else if (clist->mlist.map[y][x] == '@')
+ ft_get_weapon_two_spawn(1, y, x, clist);
+ x++;
+ }
+ x = 1;
+ y++;
+ }
+}