diff options
| author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-19 16:51:44 +0100 | 
|---|---|---|
| committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-19 16:51:44 +0100 | 
| commit | 71ee46675da86720bc7697ce607aff1ac583e65b (patch) | |
| tree | 6b5afd3c6ba957fd9fa7bb308499ec659b44d99f /src/ft_find_item.c | |
| parent | Few changes (diff) | |
| download | 42-cub3d-71ee46675da86720bc7697ce607aff1ac583e65b.tar.gz 42-cub3d-71ee46675da86720bc7697ce607aff1ac583e65b.tar.bz2 42-cub3d-71ee46675da86720bc7697ce607aff1ac583e65b.tar.xz 42-cub3d-71ee46675da86720bc7697ce607aff1ac583e65b.tar.zst 42-cub3d-71ee46675da86720bc7697ce607aff1ac583e65b.zip  | |
Player can grab weapon
Diffstat (limited to '')
| -rw-r--r-- | src/ft_find_item.c | 27 | 
1 files changed, 22 insertions, 5 deletions
diff --git a/src/ft_find_item.c b/src/ft_find_item.c index d00b62d..1c3e9a0 100644 --- a/src/ft_find_item.c +++ b/src/ft_find_item.c @@ -29,16 +29,32 @@ static uint16_t  	return (0);  } +static void +	ft_weapon_check(const char map_char, t_player *pl, t_cub *cl) +{ +	uint8_t	weap_id; + +	if (ft_ischarset(FT_CHRST_WEAPONS, map_char)) +	{ +		weap_id = (map_char == '!') ? (0) : (1); +		cl->mlist.map[(uint64_t)pl->pos_y][(uint64_t)pl->pos_x] = '0'; +		cl->weaps[weap_id][0].s_pos_x = 0; +		cl->weaps[weap_id][0].s_pos_y = 0; +		pl->has_weapon[weap_id] = 1; +		pl->handles_weapon = weap_id; +		/* TODO: ft_sfx_weapon(3) */ +	} +} +  void  	ft_find_item(t_player *pl, t_map *ml, t_cub *cl)  { -	uint16_t id; +	uint16_t	id; +	const char	map_char = ml->map[(uint64_t)pl->pos_y][(uint64_t)pl->pos_x]; -	if (ft_ischarset(FT_CHRST_ITEM, -		ml->map[(uint64_t)pl->pos_y][(uint64_t)pl->pos_x])) +	if (ft_ischarset(FT_CHRST_ITEM, map_char))  	{ -		if (ml->map[(uint64_t)pl->pos_y][(uint64_t)pl->pos_x] == '+' -			&& pl->life < 100) +		if (map_char == '+' && pl->life < 100)  		{  			pl->life += FT_HEAL_PACK_AMOUNT;  			pl->life = (pl->life > 100) ? (100) : (pl->life); @@ -49,5 +65,6 @@ void  			cl->heals[id].s_pos_y = 0;  			 /* TODO: ft_sfx_heal(3) */  		} +		ft_weapon_check(map_char, pl, cl);  	}  }  | 
