mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat: added clips for the weapon
This commit is contained in:
parent
c3cb34c3bb
commit
ee56e2fdbd
2 changed files with 24 additions and 5 deletions
25
src/main.c
25
src/main.c
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/16 15:15:08 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/09/16 16:07:09 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -48,19 +48,36 @@ void handle_shooting(t_cub3d_data *data)
|
|||
{
|
||||
if (!data->player.weapon.is_auto)
|
||||
data->keypresses.is_space_pressed = false;
|
||||
if (data->player.weapon.clip <= 0)
|
||||
return ;
|
||||
data->player.weapon.is_shooting = true;
|
||||
data->last_since_shoot = get_milliseconds();
|
||||
data->player.weapon.clip--;
|
||||
if (data->player.weapon.clip == 0)
|
||||
{
|
||||
ft_printf("reloading\n");
|
||||
if (data->player.weapon.remaining_ammos < 8)
|
||||
{
|
||||
data->player.weapon.clip = data->player.weapon.remaining_ammos;
|
||||
data->player.weapon.remaining_ammos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->player.weapon.clip = 8;
|
||||
data->player.weapon.remaining_ammos -= 8;
|
||||
}
|
||||
}
|
||||
if (data->player.aimed_zombie)
|
||||
{
|
||||
data->player.aimed_zombie->health -= 32;
|
||||
data->player.points += 10;
|
||||
ft_printf("Shooting %p, now at %d HP\n", data->player.aimed_zombie,
|
||||
data->player.aimed_zombie->health);
|
||||
ft_printf("Shooting %p, now at %d HP %d/%d\n", data->player.aimed_zombie,
|
||||
data->player.aimed_zombie->health, data->player.weapon.clip, data->player.weapon.remaining_ammos);
|
||||
if (data->player.aimed_zombie->health <= 0)
|
||||
kill_zombie(data, data->player.aimed_zombie);
|
||||
}
|
||||
else
|
||||
ft_printf("Shoot!\n");
|
||||
ft_printf("Shoot! %d/%d\n", data->player.weapon.clip, data->player.weapon.remaining_ammos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue