diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-23 00:16:36 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-23 00:16:36 +0100 |
commit | 3ebd8ba2bd2302327932d877ef8b797793a67542 (patch) | |
tree | 0a45b7f6bf98eab0895d71ac85b29413ab707be3 /src | |
parent | I think we good (diff) | |
download | 42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.tar.gz 42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.tar.bz2 42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.tar.xz 42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.tar.zst 42-cub3d-3ebd8ba2bd2302327932d877ef8b797793a67542.zip |
Cool
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_check_map_line.c | 3 | ||||
-rw-r--r-- | src/ft_extra_keys.c | 9 | ||||
-rw-r--r-- | src/ft_find_item.c | 12 | ||||
-rw-r--r-- | src/ft_get_topsp.c | 32 | ||||
-rw-r--r-- | src/ft_init_lists.c | 5 | ||||
-rw-r--r-- | src/ft_init_map.c | 2 | ||||
-rw-r--r-- | src/ft_warp_level.c | 13 |
7 files changed, 34 insertions, 42 deletions
diff --git a/src/ft_check_map_line.c b/src/ft_check_map_line.c index 9419ab2..44580db 100644 --- a/src/ft_check_map_line.c +++ b/src/ft_check_map_line.c @@ -39,9 +39,6 @@ static int8_t } cl->mlist.istraps = (line[i] == 'T') ? (1) : (cl->mlist.istraps); cl->mlist.isheals = (line[i] == '+') ? (1) : (cl->mlist.isheals); - cl->mlist.isweapon[0] = (line[i] == '!') ? (1) : (cl->mlist.isweapon[0]); - cl->mlist.isweapon[1] = (line[i] == '@') ? (1) : (cl->mlist.isweapon[1]); - ft_get_topsp(line[i], cl); return (0); } diff --git a/src/ft_extra_keys.c b/src/ft_extra_keys.c index a78f821..097e2e2 100644 --- a/src/ft_extra_keys.c +++ b/src/ft_extra_keys.c @@ -71,8 +71,15 @@ int int ft_space_key(t_cub *clist) { - if (clist->plist.fire == 0) + uint8_t w_id; + + w_id = clist->plist.handles_weapon; + w_id = (w_id == 2) ? (1) : (w_id); + w_id = (w_id == 4) ? (2) : (w_id); + if (clist->plist.fire == 0 && + (clist->plist.ammo[w_id] > 0 || clist->plist.ammo[w_id] == -4)) { + clist->plist.ammo[w_id] -= w_id; clist->sfx[clist->plist.handles_weapon + 7].sfx_play(clist->sfx); clist->plist.fire = 1; } diff --git a/src/ft_find_item.c b/src/ft_find_item.c index caeb3f4..cea05fa 100644 --- a/src/ft_find_item.c +++ b/src/ft_find_item.c @@ -30,6 +30,17 @@ static uint16_t } static void + ft_set_ammo(uint8_t weap_id, t_player *pl) +{ + if (weap_id == 0) + pl->ammo[0] = FT_WEAP_ONE_STRT_AMMO; + else if (weap_id == 1) + pl->ammo[1] = FT_WEAP_TWO_STRT_AMMO; + else if (weap_id == 2) + pl->ammo[2] = FT_WEAP_THREE_STRT_AMMO; +} + +static void ft_weapon_check(const char map_char, t_player *pl, t_cub *cl) { uint8_t weap_id; @@ -48,6 +59,7 @@ static void pl->handles_weapon = (weap_id == 0) ? (0) : (pl->handles_weapon); pl->handles_weapon = (weap_id == 1) ? (2) : (pl->handles_weapon); pl->handles_weapon = (weap_id == 2) ? (4) : (pl->handles_weapon); + ft_set_ammo(weap_id, pl); if (weap_id == 0) cl->sfx[6].sfx_play(cl->sfx); else if (weap_id == 1) diff --git a/src/ft_get_topsp.c b/src/ft_get_topsp.c deleted file mode 100644 index 84339c3..0000000 --- a/src/ft_get_topsp.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_check_map_line.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/14 17:28:34 by rbousset #+# #+# */ -/* Updated: 2020/02/14 17:28:37 by rbousset ### ########lyon.fr */ -/* */ -/* ************************************************************************** */ - -#include <libft.h> -#include <cub3d.h> -#include <stddef.h> -#include <stdint.h> - -void - ft_get_topsp(char c, t_cub *clist) -{ - (void)c; - (void)clist; - /* int8_t x; */ - - /* if ((x = ft_strlchr(FT_CHRST_SPRITES, c)) > 0) */ - /* { */ - /* if ((x + 2) > clist->mlist.topsp) */ - /* { */ - /* clist->mlist.topsp = x + 2; */ - /* } */ - /* } */ -} diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index d9a2ad2..b551aab 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -33,7 +33,7 @@ t_rgb ** -1: no weapon ** 0: weapon one ** 2: weapon two -** 4: weapon two +** 4: weapon three */ t_player @@ -55,6 +55,9 @@ t_player plist.has_weapon[1] = 0; plist.has_weapon[2] = 0; plist.handles_weapon = -1; + plist.ammo[0] = 0; + plist.ammo[1] = 0; + plist.ammo[2] = 0; plist.life = FT_STRT_LIFE; plist.fire = 0; return (plist); diff --git a/src/ft_init_map.c b/src/ft_init_map.c index a2a9ce1..1b55d17 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -97,8 +97,6 @@ int8_t mlist->isskybox = 0; mlist->istraps = 0; mlist->isheals = 0; - mlist->isweapon[0] = 0; - mlist->isweapon[1] = 0; mlist->traps_nbr = 0; mlist->heals_nbr = 0; return (ft_init_map_norme(mlist)); diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 02911b0..5055445 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -21,14 +21,18 @@ static void ft_player_keepings(t_cub *cl) { - int16_t tmp_life; - uint8_t tmp_has[3]; - int8_t tmp_handles; + int16_t tmp_life; + uint8_t tmp_has[3]; + uint16_t tmp_ammo[3]; + int8_t tmp_handles; tmp_life = cl->plist.life; tmp_has[0] = cl->plist.has_weapon[0]; tmp_has[1] = cl->plist.has_weapon[1]; tmp_has[2] = cl->plist.has_weapon[2]; + tmp_ammo[0] = cl->plist.ammo[0]; + tmp_ammo[1] = cl->plist.ammo[1]; + tmp_ammo[2] = cl->plist.ammo[2]; tmp_handles = cl->plist.handles_weapon; cl->plist = ft_init_player(); if (!cl->isdead) @@ -36,6 +40,9 @@ static void cl->plist.has_weapon[0] = tmp_has[0]; cl->plist.has_weapon[1] = tmp_has[1]; cl->plist.has_weapon[2] = tmp_has[2]; + cl->plist.ammo[0] = tmp_ammo[0]; + cl->plist.ammo[1] = tmp_ammo[1]; + cl->plist.ammo[2] = tmp_ammo[2]; cl->plist.handles_weapon = tmp_handles; } |