mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat: Added new wall type (barricades)
This commit is contained in:
parent
d295c77360
commit
35b83e4ff7
6 changed files with 17 additions and 10 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:59:37 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:59:37 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/09/05 20:26:30 by tchampio ### ########.fr */
|
/* Updated: 2025/09/09 09:55:15 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -29,6 +29,7 @@ typedef struct s_cub3d_data
|
||||||
t_img_data *so_texture;
|
t_img_data *so_texture;
|
||||||
t_img_data *we_texture;
|
t_img_data *we_texture;
|
||||||
t_img_data *ea_texture;
|
t_img_data *ea_texture;
|
||||||
|
t_img_data *barricades_texture;
|
||||||
t_img_data *img_data;
|
t_img_data *img_data;
|
||||||
t_img_data *point_figures[10];
|
t_img_data *point_figures[10];
|
||||||
t_img_data *perk_logos[3];
|
t_img_data *perk_logos[3];
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/09/03 17:02:08 by tchampio #+# #+# */
|
/* Created: 2025/09/03 17:02:08 by tchampio #+# #+# */
|
||||||
/* Updated: 2025/09/08 17:25:53 by tchampio ### ########.fr */
|
/* Updated: 2025/09/09 09:56:01 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -97,6 +97,7 @@ void load_textures(t_cub3d_data *data)
|
||||||
data->so_texture = load_single_texture(data, data->map->so_texture);
|
data->so_texture = load_single_texture(data, data->map->so_texture);
|
||||||
data->we_texture = load_single_texture(data, data->map->we_texture);
|
data->we_texture = load_single_texture(data, data->map->we_texture);
|
||||||
data->ea_texture = load_single_texture(data, data->map->ea_texture);
|
data->ea_texture = load_single_texture(data, data->map->ea_texture);
|
||||||
|
data->barricades_texture = load_single_texture(data, "ressources/barricades.xpm");
|
||||||
load_points_textures(data);
|
load_points_textures(data);
|
||||||
load_perk_logos(data);
|
load_perk_logos(data);
|
||||||
load_round_indicators(data);
|
load_round_indicators(data);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/08/06 11:25:05 by kcolin #+# #+# */
|
/* Created: 2025/08/06 11:25:05 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/08/20 12:47:52 by tchampio ### ########.fr */
|
/* Updated: 2025/09/09 10:15:46 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)
|
bool blocks_movement(t_mapdata *data, int x, int y)
|
||||||
{
|
{
|
||||||
if (out_of_bounds(data, x, y) || data->map[y][x] == '1')
|
if (out_of_bounds(data, x, y) || ft_strchr("12345678", data->map[y][x]))
|
||||||
return (true);
|
return (true);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool blocks_view(t_mapdata *data, int x, int y)
|
bool blocks_view(t_mapdata *data, int x, int y)
|
||||||
{
|
{
|
||||||
if (out_of_bounds(data, x, y) || data->map[y][x] == '1')
|
if (out_of_bounds(data, x, y) || ft_strchr("12345678", data->map[y][x]))
|
||||||
return (true);
|
return (true);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:18:13 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:18:13 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/08/18 13:46:15 by kcolin ### ########.fr */
|
/* Updated: 2025/09/08 17:51:38 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,10 +20,12 @@
|
||||||
* Q - Quick Revive perk
|
* Q - Quick Revive perk
|
||||||
* J - Juggernog perk
|
* J - Juggernog perk
|
||||||
* D - Double tap perk
|
* D - Double tap perk
|
||||||
|
* 2345678 - barricade and it's levels starting from 2 (every planks) to 8
|
||||||
|
* beware of zombies
|
||||||
*/
|
*/
|
||||||
bool has_forbidden_characters(char *line)
|
bool has_forbidden_characters(char *line)
|
||||||
{
|
{
|
||||||
static const char *allowedchars = " 10NSEWMQJDz\n";
|
static const char *allowedchars = " 102345678NSEWMQJDz\n";
|
||||||
size_t strsize;
|
size_t strsize;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/06/06 17:54:42 by tchampio #+# #+# */
|
/* Created: 2025/06/06 17:54:42 by tchampio #+# #+# */
|
||||||
/* Updated: 2025/08/12 13:43:42 by tchampio ### ########.fr */
|
/* Updated: 2025/09/09 10:01:57 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ void print_mapdata(const t_mapdata *data)
|
||||||
|
|
||||||
void flood_fill(t_mapdata *map, int x, int y)
|
void flood_fill(t_mapdata *map, int x, int y)
|
||||||
{
|
{
|
||||||
if (map->mapflood[y][x] == '1')
|
if (ft_strchr("12345678", map->mapflood[y][x]))
|
||||||
return ;
|
return ;
|
||||||
if (map->mapflood[y][x] == 'z')
|
if (map->mapflood[y][x] == 'z')
|
||||||
return ;
|
return ;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/31 13:17:39 by kcolin #+# #+# */
|
/* Created: 2025/07/31 13:17:39 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/08/06 14:15:08 by tchampio ### ########.fr */
|
/* Updated: 2025/09/09 09:59:45 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#include "ray.h"
|
#include "ray.h"
|
||||||
#include "../renderer/render.h"
|
#include "../renderer/render.h"
|
||||||
#include "../draw/drawutils.h"
|
#include "../draw/drawutils.h"
|
||||||
|
#include "../../libft/includes/libft.h"
|
||||||
|
|
||||||
t_cardinal_dir get_cardinal(t_ray *ray)
|
t_cardinal_dir get_cardinal(t_ray *ray)
|
||||||
{
|
{
|
||||||
|
|
@ -45,6 +46,8 @@ static int get_color(t_cub3d_data *data, t_ray *ray, int tex_y)
|
||||||
|| (ray->side == SOUTH && ray->dir_y > 0))
|
|| (ray->side == SOUTH && ray->dir_y > 0))
|
||||||
tex_x = TEXTURE_SIZE - tex_x - 1;
|
tex_x = TEXTURE_SIZE - tex_x - 1;
|
||||||
dir = get_cardinal(ray);
|
dir = get_cardinal(ray);
|
||||||
|
if (ft_strchr("2345678", data->map->map[ray->map_y][ray->map_x]))
|
||||||
|
return (my_mlx_pixel_get(data->barricades_texture, tex_x, tex_y));
|
||||||
if (dir == NORTH)
|
if (dir == NORTH)
|
||||||
texture = data->no_texture;
|
texture = data->no_texture;
|
||||||
else if (dir == SOUTH)
|
else if (dir == SOUTH)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue