aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h1
-rw-r--r--src/ft_get_player_spawn.c1
-rw-r--r--src/ft_get_weapon_spawn.c49
-rw-r--r--src/ft_warp_level.c6
5 files changed, 55 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 01ac1ec..cad4b1b 100644
--- a/Makefile
+++ b/Makefile
@@ -106,6 +106,7 @@ SRCS_NAME += ft_draw_heals.c
SRCS_NAME += ft_draw_heals_extra.c
SRCS_NAME += ft_find_item.c
SRCS_NAME += ft_tex_weap_init.c
+SRCS_NAME += ft_get_weapon_spawn.c
#--------------------------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
#--------------------------------------------------------------------------------------------------#
diff --git a/inc/cub3d.h b/inc/cub3d.h
index aedd550..33c8bba 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -122,6 +122,7 @@ size_t ft_get_map_w(char **map);
void ft_get_sprite_spawn(t_cub *clist);
void ft_get_trap_spawn(t_cub *clist);
void ft_get_heal_spawn(t_cub *clist);
+void ft_get_weapon_spawn(t_cub *clist);
int8_t ft_check_map_line(char *line, uint8_t l, t_cub *clist);
int8_t ft_check_ext(const char *filep, const char *ext);
int8_t ft_check_not_found(const char *path);
diff --git a/src/ft_get_player_spawn.c b/src/ft_get_player_spawn.c
index 1ba6437..2f8fa0e 100644
--- a/src/ft_get_player_spawn.c
+++ b/src/ft_get_player_spawn.c
@@ -85,6 +85,7 @@ void
ft_get_sprite_spawn(clist);
ft_get_trap_spawn(clist);
ft_get_heal_spawn(clist);
+ ft_get_weapon_spawn(clist);
return ;
}
x++;
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++;
+ }
+}
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index d6a3d7f..6962a1d 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -12,13 +12,13 @@
#include <libft.h>
#include <cub3d.h>
-#include <stdlib.h>
+#include <mlx.h>
#include <stddef.h>
+#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <signal.h>
-#include <sys/wait.h>
-#include <mlx.h>
+#include <pthread.h>
static void
ft_del_map(t_map *ml)