feat: added door in the game (can't open right now)

This commit is contained in:
Theo Champion 2025-09-30 17:50:49 +02:00
parent 94f018d23b
commit ebd4b282cf
7 changed files with 272 additions and 9 deletions

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:59:37 by kcolin #+# #+# */
/* Updated: 2025/09/22 17:17:23 by tchampio ### ########.fr */
/* Updated: 2025/09/30 17:32:50 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -36,6 +36,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 *door_texture;
t_mapdata *map;
t_player player;
t_keypresses keypresses;

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/03 17:02:08 by tchampio #+# #+# */
/* Updated: 2025/09/22 17:17:34 by tchampio ### ########.fr */
/* Updated: 2025/09/30 17:35:31 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -109,6 +109,7 @@ void load_textures(t_cub3d_data *data)
"ressources/barricades_6.xpm");
data->barricades_texture[5] = load_single_texture(data,
"ressources/barricades_7.xpm");
data->door_texture = load_single_texture(data, "ressources/door.xpm");
load_points_textures(data);
load_perk_logos(data);
load_round_indicators(data);

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/06 11:25:05 by kcolin #+# #+# */
/* Updated: 2025/09/09 10:15:46 by tchampio ### ########.fr */
/* Updated: 2025/09/30 17:43:36 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,14 +25,14 @@ static bool out_of_bounds(t_mapdata *data, int x, int y)
bool blocks_movement(t_mapdata *data, int x, int y)
{
if (out_of_bounds(data, x, y) || ft_strchr("12345678", data->map[y][x]))
if (out_of_bounds(data, x, y) || ft_strchr("12345678d", data->map[y][x]))
return (true);
return (false);
}
bool blocks_view(t_mapdata *data, int x, int y)
{
if (out_of_bounds(data, x, y) || ft_strchr("12345678", data->map[y][x]))
if (out_of_bounds(data, x, y) || ft_strchr("12345678d", data->map[y][x]))
return (true);
return (false);
}

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:18:13 by kcolin #+# #+# */
/* Updated: 2025/09/22 17:16:41 by tchampio ### ########.fr */
/* Updated: 2025/09/30 17:23:06 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,11 +21,13 @@
* J - Juggernog perk
* D - Double tap perk
* 2345678 - barricade and it's levels starting from 2 (every planks) to 8
* beware of zombies
* z - beware of zombies
* d - closed door
* i - open dooro
*/
bool has_forbidden_characters(char *line)
{
static const char *allowedchars = " 10234567NSEWMQJDz\n";
static const char *allowedchars = " 10234567NSEWMQJDzdi\n";
size_t strsize;
int i;

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/31 13:17:39 by kcolin #+# #+# */
/* Updated: 2025/09/22 17:17:54 by tchampio ### ########.fr */
/* Updated: 2025/09/30 17:41:52 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -66,6 +66,8 @@ static int get_color(t_cub3d_data *data, t_ray *ray, int tex_y)
if (ft_strchr("234567", data->map->map[ray->map_y][ray->map_x]))
return (my_mlx_pixel_get(get_right_barricade(data,
data->map->map[ray->map_y][ray->map_x]), tex_x, tex_y));
if (data->map->map[ray->map_y][ray->map_x] == 'd')
return (my_mlx_pixel_get(data->door_texture, tex_x, tex_y));
if (dir == NORTH)
texture = data->no_texture;
else if (dir == SOUTH)