Compare commits

..

4 commits

Author SHA1 Message Date
Theo Champion
4a513e9877 fix: Fix crash when no map 2025-10-07 13:49:55 +02:00
Theo Champion
cf3801702d fix: Made crosshair bigger 2025-10-07 13:41:19 +02:00
Theo Champion
0e99c6da49 feat: Made a the box usable 2025-10-07 12:51:54 +02:00
Theo Champion
6158618d36 fix: Reverted base weapon to the base gun 2025-10-07 12:51:38 +02:00
5 changed files with 24 additions and 11 deletions

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:54:36 by kcolin #+# #+# */
/* Updated: 2025/08/19 20:07:29 by tchampio ### ########.fr */
/* Updated: 2025/10/07 13:49:26 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -53,7 +53,7 @@
# define ENOCUB "Not a .cub file"
# define EOPEN "Can't open file"
# define EMALMAP "Map is malformed (invalid chars or missing walls)"
# define ENOPLAYER "No player"
# define ENOPLAYER "No player or no map (monster!!)"
# define EHOLES "Holes in map"
# define ETRAILING "Trailing chars after map"
# define EBADCHARCOLOR "invalid characters in color definition"

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* hud.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* By: freddy <freddy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/08 17:27:12 by tchampio #+# #+# */
/* Updated: 2025/09/17 16:55:05 by tchampio ### ########.fr */
/* Updated: 2025/10/07 13:41:00 by freddy ### ########.fr */
/* */
/* ************************************************************************** */
@ -91,4 +91,8 @@ void create_hud(t_cub3d_data *data)
matrix_image_put(data, data->player.weapon->texture,
WIDTH / 2, HEIGHT - 175);
matrix_set(data, WIDTH / 2, HEIGHT / 2, 0x0000FF00);
matrix_set(data, WIDTH / 2 + 1, HEIGHT / 2, 0x0000FF00);
matrix_set(data, WIDTH / 2 - 1, HEIGHT / 2, 0x0000FF00);
matrix_set(data, WIDTH / 2, HEIGHT / 2 + 1, 0x0000FF00);
matrix_set(data, WIDTH / 2, HEIGHT / 2 - 1, 0x0000FF00);
}

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:15:26 by kcolin #+# #+# */
/* Updated: 2025/10/03 23:51:46 by tchampio ### ########.fr */
/* Updated: 2025/10/07 13:48:17 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -74,7 +74,7 @@ bool check_bare_minimum(t_mapdata *map)
i = 0;
spawncount = 0;
while (map->map[i])
while (map->map && map->map[i])
{
j = 0;
while (map->map[i][j])

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/06 11:29:14 by kcolin #+# #+# */
/* Updated: 2025/09/18 12:06:58 by tchampio ### ########.fr */
/* Updated: 2025/10/07 12:49:37 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -64,7 +64,7 @@ void init_player(t_cub3d_data *data, t_player *player, t_mapdata *map)
player->health = 100;
player->points = 500;
ft_bzero(player->perk_order, 3);
player->weapon = data->weaponsregistry[1];
player->weapon = data->weaponsregistry[0];
if (dir == 'N' || dir == 'S')
init_lon(player, dir);
else

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/03 18:18:04 by tchampio #+# #+# */
/* Updated: 2025/10/03 18:19:03 by tchampio ### ########.fr */
/* Updated: 2025/10/07 12:51:07 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -50,6 +50,13 @@ void pay_and_give(t_cub3d_data *data, t_sprite *current_sprite)
if (last_perk_pos > 2)
return ;
symbol = data->map->map[(int)current_sprite->y][(int)current_sprite->x];
if (symbol == 'M' && pay(data, 950, false)
&& data->player.weapon != data->weaponsregistry[1])
{
data->player.weapon = data->weaponsregistry[1];
ft_printf("Gave player enhanced gun\n");
}
else
pick_right_perk(symbol, data, &last_perk_pos);
}
@ -62,7 +69,9 @@ void handle_sprite_interactions(t_cub3d_data *data)
if (data->sprite_distances[data->sprite_counter - 1] <= 1.5)
{
if (data->sprite_list[data->sprite_order[data->sprite_counter - 1]]
->sprite_type == PERK)
->sprite_type == PERK
|| data->sprite_list
[data->sprite_order[data->sprite_counter - 1]]->sprite_type == BOX)
{
if (data->keypresses.is_f_pressed)
{