mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
norme: Fixed norme issue for the sprite interaction
This commit is contained in:
parent
f325eb3dbf
commit
55643a3d59
4 changed files with 54 additions and 13 deletions
|
|
@ -6,13 +6,14 @@
|
|||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/08/05 15:51:01 by tchampio #+# #+# */
|
||||
/* Updated: 2025/09/15 15:41:09 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/10/03 18:20:05 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../cub3d_data.h"
|
||||
#include "../draw/drawutils.h"
|
||||
#include "../renderer/render.h"
|
||||
#include "sprite_interactions.h"
|
||||
#include "sort_sprites.h"
|
||||
#include <math.h>
|
||||
#include "../../libft/includes/libft.h"
|
||||
|
|
@ -113,18 +114,7 @@ void sprite_caster(t_cub3d_data *data)
|
|||
if (!data->sprite_list || !data->sprite_list[0])
|
||||
return ;
|
||||
sort_sprites(data->sprite_order, data->sprite_distances, data);
|
||||
if (data->sprite_distances[data->sprite_counter - 1] <= 1.5)
|
||||
{
|
||||
if (data->sprite_list[data->sprite_order[data->sprite_counter - 1]]
|
||||
->sprite_type == PERK)
|
||||
{
|
||||
if (data->keypresses.is_f_pressed)
|
||||
{
|
||||
data->keypresses.is_f_pressed = false;
|
||||
ft_printf("🎵You need a little revive🎵\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
handle_sprite_interactions(data);
|
||||
i = 0;
|
||||
while (data->sprite_list[i] && i < MAX_SPRITES)
|
||||
{
|
||||
|
|
|
|||
30
src/sprites/sprite_interactions.c
Normal file
30
src/sprites/sprite_interactions.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* sprite_interactions.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/03 18:18:04 by tchampio #+# #+# */
|
||||
/* Updated: 2025/10/03 18:19:03 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../cub3d_data.h"
|
||||
#include "../../libft/includes/libft.h"
|
||||
|
||||
void handle_sprite_interactions(t_cub3d_data *data)
|
||||
{
|
||||
if (data->sprite_distances[data->sprite_counter - 1] <= 1.5)
|
||||
{
|
||||
if (data->sprite_list[data->sprite_order[data->sprite_counter - 1]]
|
||||
->sprite_type == PERK)
|
||||
{
|
||||
if (data->keypresses.is_f_pressed)
|
||||
{
|
||||
data->keypresses.is_f_pressed = false;
|
||||
ft_printf("🎵You need a little revive🎵\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/sprites/sprite_interactions.h
Normal file
20
src/sprites/sprite_interactions.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* sprite_interactions.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/03 18:19:22 by tchampio #+# #+# */
|
||||
/* Updated: 2025/10/03 18:21:00 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SPRITE_INTERACTIONS_H
|
||||
# define SPRITE_INTERACTIONS_H
|
||||
|
||||
# include "../cub3d_data.h"
|
||||
|
||||
void handle_sprite_interactions(t_cub3d_data *data);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue