feat: Made a the box usable

This commit is contained in:
Theo Champion 2025-10-07 12:51:54 +02:00
parent 6158618d36
commit 0e99c6da49

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */ /* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/03 18:18:04 by tchampio #+# #+# */ /* Created: 2025/10/03 18:18:04 by tchampio #+# #+# */
/* Updated: 2025/10/03 18:19:03 by tchampio ### ########.fr */ /* Updated: 2025/10/07 12:51:07 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -50,7 +50,14 @@ void pay_and_give(t_cub3d_data *data, t_sprite *current_sprite)
if (last_perk_pos > 2) if (last_perk_pos > 2)
return ; return ;
symbol = data->map->map[(int)current_sprite->y][(int)current_sprite->x]; symbol = data->map->map[(int)current_sprite->y][(int)current_sprite->x];
pick_right_perk(symbol, data, &last_perk_pos); if (symbol == 'M' && pay(data, 950, false)
&& data->player.weapon != data->weaponsregistry[1])
{
data->player.weapon = data->weaponsregistry[1];
ft_printf("Gave player enhanced gun\n");
}
else
pick_right_perk(symbol, data, &last_perk_pos);
} }
void handle_sprite_interactions(t_cub3d_data *data) void handle_sprite_interactions(t_cub3d_data *data)
@ -62,7 +69,9 @@ void handle_sprite_interactions(t_cub3d_data *data)
if (data->sprite_distances[data->sprite_counter - 1] <= 1.5) if (data->sprite_distances[data->sprite_counter - 1] <= 1.5)
{ {
if (data->sprite_list[data->sprite_order[data->sprite_counter - 1]] if (data->sprite_list[data->sprite_order[data->sprite_counter - 1]]
->sprite_type == PERK) ->sprite_type == PERK
|| data->sprite_list
[data->sprite_order[data->sprite_counter - 1]]->sprite_type == BOX)
{ {
if (data->keypresses.is_f_pressed) if (data->keypresses.is_f_pressed)
{ {