From c1d1d76e0c88fbbbe4b1e0611a13a6a4df6cb424 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 11 Mar 2020 09:59:17 +0100 Subject: Parsed traps --- src/ft_get_traps.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/ft_get_traps.c (limited to 'src/ft_get_traps.c') diff --git a/src/ft_get_traps.c b/src/ft_get_traps.c new file mode 100644 index 0000000..cdc05de --- /dev/null +++ b/src/ft_get_traps.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_get_tex_nl.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/28 18:24:52 by rbousset #+# #+# */ +/* Updated: 2020/02/28 18:24:56 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include + +int8_t + ft_get_traps(char **words, t_cub *clist) +{ + if (!(*words) || !(*(words + 1)) || (*(words + 2))) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS); + return (-1); + } + if (ft_check_ext(*(words + 1), ".xpm") < 0) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); + return (-1); + } + ft_memdel((void**)&clist->mlist.traps_path); + if (!(clist->mlist.traps_path = ft_strdup(*(words + 1)))) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); + return (-1); + } + if (ft_check_not_found(clist->mlist.traps_path) < 0) + { + ft_sprintf(clist->errmsg, FT_ERR_RD_TRAP); + return (-1); + } + return (0); +} -- cgit v1.2.3 From c581c7e3543058f015bddf96d76ac2d771ea40a0 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 11 Mar 2020 10:16:48 +0100 Subject: Nice parse --- src/ft_get_traps.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/ft_get_traps.c') diff --git a/src/ft_get_traps.c b/src/ft_get_traps.c index cdc05de..0235bb5 100644 --- a/src/ft_get_traps.c +++ b/src/ft_get_traps.c @@ -14,6 +14,34 @@ #include #include +void + ft_get_trap_spawn(t_cub *clist) +{ + size_t x; + size_t y; + uint8_t i; + + x = 1; + y = 1; + i = 0; + while (clist->mlist.map[y]) + { + while (clist->mlist.map[y][x]) + { + if (clist->mlist.map[y][x] == 'T') + { + clist->mlist.traps_nbr++; + clist->traps[i].s_pos_x = x; + clist->traps[i].s_pos_y = y; + i++; + } + x++; + } + x = 1; + y++; + } +} + int8_t ft_get_traps(char **words, t_cub *clist) { -- cgit v1.2.3