mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat: Made zombies killable
Code is almost normed I will make a function to handle sprites interractions
This commit is contained in:
parent
46b40540dc
commit
37bb56733e
6 changed files with 37 additions and 10 deletions
20
src/main.c
20
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 14:09:13 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/09/15 15:45:27 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -34,12 +34,29 @@
|
|||
#include "sprites/move_sprites.h"
|
||||
#include "hud/hud.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void handle_shooting(t_cub3d_data *data)
|
||||
{
|
||||
if (data->keypresses.is_space_pressed)
|
||||
{
|
||||
if (!data->player.weapon.is_auto)
|
||||
data->keypresses.is_space_pressed = false;
|
||||
if (data->player.aimed_zombie)
|
||||
{
|
||||
data->player.aimed_zombie->health -= 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)
|
||||
kill_zombie(data, data->player.aimed_zombie);
|
||||
}
|
||||
else
|
||||
ft_printf("Shoot!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +73,6 @@ int game_loop(t_cub3d_data *data)
|
|||
move_sprites(data);
|
||||
data->player.aimed_zombie = NULL;
|
||||
raycaster(data, &ray);
|
||||
ft_printf("Current aimed %p\n", data->player.aimed_zombie);
|
||||
sprite_caster(data);
|
||||
create_hud(data);
|
||||
matrix_to_image(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue