mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat: Added a cheat for ammos
This commit is contained in:
parent
c339bb7334
commit
0b00f5608c
2 changed files with 10 additions and 8 deletions
14
src/main.c
14
src/main.c
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/17 13:36:22 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/09/17 16:20:34 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -48,17 +48,12 @@ 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 ;
|
||||
if (data->last_since_shoot != 0 && data->player.weapon.is_auto)
|
||||
{
|
||||
if (get_milliseconds() - data->last_since_shoot < 50000)
|
||||
return ;
|
||||
}
|
||||
data->player.weapon.is_shooting = true;
|
||||
data->last_since_shoot = get_milliseconds();
|
||||
data->player.weapon.clip--;
|
||||
if (data->player.weapon.clip == 0)
|
||||
if (data->player.weapon.clip <= 0 && data->player.weapon.remaining_ammos > 0)
|
||||
{
|
||||
ft_printf("reloading\n");
|
||||
if (data->player.weapon.remaining_ammos < 8)
|
||||
|
|
@ -72,6 +67,11 @@ void handle_shooting(t_cub3d_data *data)
|
|||
data->player.weapon.remaining_ammos -= 8;
|
||||
}
|
||||
}
|
||||
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.aimed_zombie)
|
||||
{
|
||||
data->player.aimed_zombie->health -= 32;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:22:57 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/14 15:57:54 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/09/17 16:12:06 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -43,6 +43,8 @@ int keypress_handler(int keycode, t_cub3d_data *data)
|
|||
data->player.points += 500;
|
||||
if (keycode == XK_u)
|
||||
data->round++;
|
||||
if (keycode == XK_m)
|
||||
data->player.weapon.remaining_ammos = 1337;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue