mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat: Added perk buy
This commit is contained in:
parent
55643a3d59
commit
3987a1dec1
7 changed files with 223 additions and 2439 deletions
|
|
@ -17,7 +17,7 @@ bool pay(t_cub3d_data *data, int amount, bool isdoor)
|
|||
{
|
||||
if (data->player.points < amount)
|
||||
{
|
||||
ft_printf("Not enough points :(\n");
|
||||
ft_printf("Not enough points >:( 🖕\n");
|
||||
return (false);
|
||||
}
|
||||
data->player.points -= amount;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
#include "../player/player.h"
|
||||
#include "../consts.h"
|
||||
#include "../cub3d_data.h"
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include "../map/collision.h"
|
||||
#define FLT_EPSILON 1.19209290e-7F
|
||||
|
||||
void init_ray(t_ray *ray, int pos_x, t_player *player)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,9 +12,53 @@
|
|||
|
||||
#include "../cub3d_data.h"
|
||||
#include "../../libft/includes/libft.h"
|
||||
#include "../player/pay.h"
|
||||
|
||||
void pick_right_perk(char symbol, t_cub3d_data *data, int *last_perk)
|
||||
{
|
||||
if (symbol == 'J' && !data->player.has_juggernog)
|
||||
{
|
||||
if (pay(data, 2500, false))
|
||||
{
|
||||
data->player.perk_order[(*last_perk)++] = JUGGERNOG;
|
||||
data->player.has_juggernog = true;
|
||||
}
|
||||
}
|
||||
else if (symbol == 'Q' && !data->player.has_revive)
|
||||
{
|
||||
if (pay(data, 1500, false))
|
||||
{
|
||||
data->player.perk_order[(*last_perk)++] = REVIVE;
|
||||
data->player.has_revive = true;
|
||||
}
|
||||
}
|
||||
else if (symbol == 'D' && !data->player.has_doubletap)
|
||||
{
|
||||
if (pay(data, 2000, false))
|
||||
{
|
||||
data->player.perk_order[(*last_perk)++] = DOUBLETAP;
|
||||
data->player.has_doubletap = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pay_and_give(t_cub3d_data *data, t_sprite *current_sprite)
|
||||
{
|
||||
static int last_perk_pos = 0;
|
||||
char symbol;
|
||||
|
||||
if (last_perk_pos > 2)
|
||||
return ;
|
||||
symbol = data->map->map[(int)current_sprite->y][(int)current_sprite->x];
|
||||
pick_right_perk(symbol, data, &last_perk_pos);
|
||||
}
|
||||
|
||||
void handle_sprite_interactions(t_cub3d_data *data)
|
||||
{
|
||||
t_sprite *current_sprite;
|
||||
|
||||
current_sprite = data->sprite_list
|
||||
[data->sprite_order[data->sprite_counter - 1]];
|
||||
if (data->sprite_distances[data->sprite_counter - 1] <= 1.5)
|
||||
{
|
||||
if (data->sprite_list[data->sprite_order[data->sprite_counter - 1]]
|
||||
|
|
@ -23,7 +67,7 @@ void handle_sprite_interactions(t_cub3d_data *data)
|
|||
if (data->keypresses.is_f_pressed)
|
||||
{
|
||||
data->keypresses.is_f_pressed = false;
|
||||
ft_printf("🎵You need a little revive🎵\n");
|
||||
pay_and_give(data, current_sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue