mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat: Added point counter at the right of the screen (basic)
This commit is contained in:
parent
4a2b4eb287
commit
792d8fc37a
1 changed files with 23 additions and 3 deletions
26
src/main.c
26
src/main.c
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
||||
/* Updated: 2025/08/20 13:52:42 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/08/20 15:46:50 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#include "utils/frees.h"
|
||||
#include "utils/hooks.h"
|
||||
#include "utils/inits.h"
|
||||
#include "draw/drawutils.h"
|
||||
#include <bits/types/struct_timeval.h>
|
||||
#include <stdbool.h>
|
||||
#include <X11/keysym.h>
|
||||
|
|
@ -33,6 +34,26 @@
|
|||
#include "utils/time.h"
|
||||
#include "sprites/move_sprites.h"
|
||||
|
||||
void draw_points(t_cub3d_data *data)
|
||||
{
|
||||
char points_str[10];
|
||||
|
||||
ft_itoa_static(data->player.points, points_str, 9);
|
||||
mlx_string_put(data->mlx, data->mlx_win, WIDTH - 20, HEIGHT / 2, 0x0000FF,
|
||||
points_str);
|
||||
}
|
||||
|
||||
void create_hud(t_cub3d_data *data)
|
||||
{
|
||||
mlx_string_put(data->mlx, data->mlx_win, 10, 10, 0x00FFFFFF, COMPILED_TEXT);
|
||||
// draw points
|
||||
draw_points(data);
|
||||
// draw perks
|
||||
// draw weapon
|
||||
// draw map
|
||||
draw_map(data->map, &data->player, data->img_data);
|
||||
}
|
||||
|
||||
int game_loop(t_cub3d_data *data)
|
||||
{
|
||||
t_ray ray;
|
||||
|
|
@ -46,10 +67,9 @@ int game_loop(t_cub3d_data *data)
|
|||
raycaster(data, &ray);
|
||||
sprite_caster(data);
|
||||
matrix_to_image(data);
|
||||
draw_map(data->map, &data->player, data->img_data);
|
||||
mlx_put_image_to_window(data->mlx, data->mlx_win,
|
||||
data->img_data->img, 0, 0);
|
||||
mlx_string_put(data->mlx, data->mlx_win, 10, 10, 0x00FFFFFF, COMPILED_TEXT);
|
||||
create_hud(data);
|
||||
data->delta = (get_milliseconds() - data->last_tick);
|
||||
fps = 1000000.0 / data->delta;
|
||||
ft_itoa_static(fps, fps_string, 4);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue