mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
enhancement: Added a nuzzle flash for the gun
This commit is contained in:
parent
b94e722ab9
commit
c3cb34c3bb
6 changed files with 6695 additions and 8 deletions
13
src/main.c
13
src/main.c
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/15 15:45:27 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/09/16 15:15:08 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -39,6 +39,7 @@ void kill_zombie(t_cub3d_data *data, t_sprite *zombie_ptr)
|
|||
mlx_destroy_image(data->mlx, zombie_ptr->image->img);
|
||||
free(zombie_ptr->image);
|
||||
zombie_ptr->sprite_type = DEAD_ZOMBIE;
|
||||
data->player.points += 60;
|
||||
}
|
||||
|
||||
void handle_shooting(t_cub3d_data *data)
|
||||
|
|
@ -47,9 +48,12 @@ void handle_shooting(t_cub3d_data *data)
|
|||
{
|
||||
if (!data->player.weapon.is_auto)
|
||||
data->keypresses.is_space_pressed = false;
|
||||
data->player.weapon.is_shooting = true;
|
||||
data->last_since_shoot = get_milliseconds();
|
||||
if (data->player.aimed_zombie)
|
||||
{
|
||||
data->player.aimed_zombie->health -= 10;
|
||||
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);
|
||||
if (data->player.aimed_zombie->health <= 0)
|
||||
|
|
@ -75,6 +79,11 @@ int game_loop(t_cub3d_data *data)
|
|||
raycaster(data, &ray);
|
||||
sprite_caster(data);
|
||||
create_hud(data);
|
||||
if (data->player.weapon.is_shooting)
|
||||
{
|
||||
if (get_milliseconds() - data->last_since_shoot > 7000)
|
||||
data->player.weapon.is_shooting = false;
|
||||
}
|
||||
matrix_to_image(data);
|
||||
mlx_put_image_to_window(data->mlx, data->mlx_win,
|
||||
data->img_data->img, 0, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue