mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
feat(points): Finished point counter on the right of the screen
Some things are temporary, like the load single image function that still has comments. I'll make a function like this to restore the original code (almost). I'll also pass the pathes as constants for the sake of maintainabilty and try to avoid some of the magic values in the code for the same purpose.
This commit is contained in:
parent
242cbe3c7c
commit
761d126ba2
13 changed files with 444 additions and 122 deletions
24
src/main.c
24
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 15:46:50 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/08/20 17:06:37 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -36,22 +36,28 @@
|
|||
|
||||
void draw_points(t_cub3d_data *data)
|
||||
{
|
||||
char points_str[10];
|
||||
char points_str[11];
|
||||
int i;
|
||||
int horizontalpos;
|
||||
|
||||
ft_itoa_static(data->player.points, points_str, 9);
|
||||
mlx_string_put(data->mlx, data->mlx_win, WIDTH - 20, HEIGHT / 2, 0x0000FF,
|
||||
points_str);
|
||||
ft_itoa_static(data->player.points, points_str, 11);
|
||||
i = 0;
|
||||
horizontalpos = 250;
|
||||
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 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)
|
||||
|
|
@ -66,10 +72,12 @@ int game_loop(t_cub3d_data *data)
|
|||
move_sprites(data);
|
||||
raycaster(data, &ray);
|
||||
sprite_caster(data);
|
||||
create_hud(data);
|
||||
matrix_to_image(data);
|
||||
mlx_put_image_to_window(data->mlx, data->mlx_win,
|
||||
data->img_data->img, 0, 0);
|
||||
create_hud(data);
|
||||
draw_map(data->map, &data->player, data->img_data);
|
||||
mlx_string_put(data->mlx, data->mlx_win, 10, 10, 0x00FFFFFF, COMPILED_TEXT);
|
||||
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