2025-09-08 17:33:05 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
|
/* */
|
|
|
|
|
/* ::: :::::::: */
|
|
|
|
|
/* hud.c :+: :+: :+: */
|
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
|
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
|
/* Created: 2025/09/08 17:27:12 by tchampio #+# #+# */
|
2025-09-11 23:41:00 +02:00
|
|
|
/* Updated: 2025/09/10 15:59:15 by tchampio ### ########.fr */
|
2025-09-08 17:33:05 +02:00
|
|
|
/* */
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
#include "../cub3d_data.h"
|
|
|
|
|
#include "../../libft/includes/libft.h"
|
|
|
|
|
#include "../renderer/render.h"
|
|
|
|
|
|
|
|
|
|
void draw_points(t_cub3d_data *data)
|
|
|
|
|
{
|
|
|
|
|
char points_str[11];
|
|
|
|
|
int i;
|
|
|
|
|
int horizontalpos;
|
|
|
|
|
|
|
|
|
|
ft_itoa_static(data->player.points, points_str, 11);
|
|
|
|
|
i = 0;
|
|
|
|
|
horizontalpos = 170;
|
|
|
|
|
while (i < (int)ft_strlen(points_str))
|
|
|
|
|
{
|
|
|
|
|
matrix_image_put(data, data->point_figures[points_str[i] - '0'],
|
|
|
|
|
WIDTH - horizontalpos, HEIGHT / 2);
|
|
|
|
|
horizontalpos -= 25;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_perks(t_cub3d_data *data)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int perk_pos;
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
perk_pos = 50;
|
|
|
|
|
while (i < 3)
|
|
|
|
|
{
|
|
|
|
|
if (data->player.perk_order[i] != NONE)
|
|
|
|
|
{
|
|
|
|
|
if (data->player.perk_order[i] == REVIVE)
|
|
|
|
|
matrix_image_put(data, data->perk_logos[1], perk_pos, HEIGHT
|
|
|
|
|
- 200);
|
|
|
|
|
else if (data->player.perk_order[i] == JUGGERNOG)
|
|
|
|
|
matrix_image_put(data, data->perk_logos[0], perk_pos, HEIGHT
|
|
|
|
|
- 200);
|
|
|
|
|
else if (data->player.perk_order[i] == DOUBLETAP)
|
|
|
|
|
matrix_image_put(data, data->perk_logos[2], perk_pos, HEIGHT
|
|
|
|
|
- 200);
|
|
|
|
|
perk_pos += 50;
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_round(t_cub3d_data *data)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int pos;
|
|
|
|
|
char round_str[5];
|
|
|
|
|
|
|
|
|
|
if (data->round <= 5)
|
|
|
|
|
return (matrix_image_put(data, data->tally_marks[data->round - 1], 20,
|
|
|
|
|
HEIGHT - 85));
|
|
|
|
|
pos = 20;
|
|
|
|
|
i = 0;
|
|
|
|
|
ft_itoa_static(data->round, round_str, 5);
|
|
|
|
|
while (round_str[i])
|
|
|
|
|
{
|
|
|
|
|
matrix_image_put(data, data->round_figures[round_str[i] - '0'], pos,
|
|
|
|
|
HEIGHT - 85);
|
|
|
|
|
pos += 50;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void create_hud(t_cub3d_data *data)
|
|
|
|
|
{
|
|
|
|
|
draw_points(data);
|
|
|
|
|
draw_perks(data);
|
|
|
|
|
draw_round(data);
|
2025-09-11 23:41:00 +02:00
|
|
|
matrix_image_put(data, data->player.weapon.texture, WIDTH / 2, HEIGHT - 175);
|
2025-09-08 17:33:05 +02:00
|
|
|
}
|