Compare commits

...

4 commits

Author SHA1 Message Date
Theo Champion
f407f5b7ce fix: fixed textures leaks 2025-09-08 17:11:58 +02:00
Theo Champion
80150ce24d removal(minimap): Removed zombie tile 2025-09-08 13:59:35 +02:00
Theo Champion
baccf93ac3 fix: changed ifs to else ifs for the perk hud code 2025-09-08 13:58:03 +02:00
Theo Champion
416b7a833d Added weapon hud 2025-09-08 10:36:52 +02:00
8 changed files with 6718 additions and 11 deletions

6668
ressources/weapon.xpm Normal file

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:59:37 by kcolin #+# #+# */
/* Updated: 2025/09/03 18:22:15 by tchampio ### ########.fr */
/* Updated: 2025/09/05 20:26:30 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -34,6 +34,7 @@ typedef struct s_cub3d_data
t_img_data *perk_logos[3];
t_img_data *tally_marks[5];
t_img_data *round_figures[10];
t_img_data *gun;
t_mapdata *map;
t_player player;
t_keypresses keypresses;

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:20:00 by kcolin #+# #+# */
/* Updated: 2025/08/05 15:20:47 by kcolin ### ########.fr */
/* Updated: 2025/09/08 13:58:59 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -77,8 +77,6 @@ void draw_map(t_mapdata *map, t_player *player, t_img_data *data)
{
if (map->map[i][j] == '1')
draw_2d_wall(map->f_color, data, MAP_SIZE * j, MAP_SIZE * i);
else if (map->map[i][j] == 'Z' || map->map[i][j] == 'z')
draw_2d_wall(0x0008D9D6, data, MAP_SIZE * j, MAP_SIZE * i);
else if (map->map[i][j] == 'D' || map->map[i][j] == 'd')
draw_2d_wall(0x00FF2E63, data, MAP_SIZE * j, MAP_SIZE * i);
else if (map->map[i][j] == 's')

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/03 17:02:08 by tchampio #+# #+# */
/* Updated: 2025/09/03 18:24:18 by tchampio ### ########.fr */
/* Updated: 2025/09/05 20:26:20 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -92,4 +92,5 @@ void load_textures(t_cub3d_data *data)
load_points_textures(data);
load_perk_logos(data);
load_round_indicators(data);
data->gun = load_hud_texture(data, "ressources/weapon.xpm");
}

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
/* Updated: 2025/09/03 18:31:54 by tchampio ### ########.fr */
/* Updated: 2025/09/08 13:56:27 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -64,9 +64,9 @@ void draw_perks(t_cub3d_data *data)
{
if (data->player.perk_order[i] == REVIVE)
matrix_image_put(data, data->perk_logos[1], perk_pos, HEIGHT - 200);
if (data->player.perk_order[i] == JUGGERNOG)
else if (data->player.perk_order[i] == JUGGERNOG)
matrix_image_put(data, data->perk_logos[0], perk_pos, HEIGHT - 200);
if (data->player.perk_order[i] == DOUBLETAP)
else if (data->player.perk_order[i] == DOUBLETAP)
matrix_image_put(data, data->perk_logos[2], perk_pos, HEIGHT - 200);
perk_pos += 50;
}
@ -102,6 +102,7 @@ void create_hud(t_cub3d_data *data)
// draw round
draw_round(data);
// draw weapon
matrix_image_put(data, data->gun, WIDTH / 2, HEIGHT - 175);
// draw map
}

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/18 13:05:31 by kcolin #+# #+# */
/* Updated: 2025/08/18 13:05:31 by kcolin ### ########.fr */
/* Updated: 2025/09/08 17:02:43 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,6 +14,15 @@
#include "../../mlx/mlx.h"
#include <stdlib.h>
void destroy_texture(t_cub3d_data *data, t_img_data *data_img)
{
if (data)
{
mlx_destroy_image(data->mlx, data_img->img);
}
free(data_img);
}
void destroy_textures(t_cub3d_data *data)
{
if (data->no_texture)
@ -45,3 +54,30 @@ void destroy_sprites(t_cub3d_data *data)
sprite++;
}
}
void destroy_hud_textures(t_cub3d_data *data)
{
int i;
i = 0;
while (i < 10)
{
destroy_texture(data, data->point_figures[i++]);
}
i = 0;
while (i < 10)
{
destroy_texture(data, data->round_figures[i++]);
}
i = 0;
while (i < 5)
{
destroy_texture(data, data->tally_marks[i++]);
}
i = 0;
while (i < 3)
{
destroy_texture(data, data->perk_logos[i++]);
}
destroy_texture(data, data->gun);
}

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/11 12:07:48 by tchampio #+# #+# */
/* Updated: 2025/08/11 12:10:21 by tchampio ### ########.fr */
/* Updated: 2025/09/08 14:15:25 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,5 +17,6 @@
void destroy_textures(t_cub3d_data *data);
void destroy_sprites(t_cub3d_data *data);
void destroy_hud_textures(t_cub3d_data *data);
#endif

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 13:59:27 by kcolin #+# #+# */
/* Updated: 2025/08/12 15:38:45 by tchampio ### ########.fr */
/* Updated: 2025/09/08 14:15:58 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -67,6 +67,7 @@ int destroy(t_cub3d_data *data, int exit_code)
if (data->img_data)
mlx_destroy_image(data->mlx, data->img_data->img);
destroy_textures(data);
destroy_hud_textures(data);
destroy_sprites(data);
free(data->img_data);
if (data->mlx)