Started bonus part

- added bonus rules in makefile
- added a BONUS define for bonus
- added a conditional check for characters
This commit is contained in:
Theo Champion 2025-07-02 15:35:05 +02:00
parent 34db19c1a2
commit 5c1d469cac
7 changed files with 93 additions and 27 deletions

View file

@ -1,11 +1,12 @@
CC=cc CC=cc
SANITIZERS=-fsanitize=address -fno-omit-frame-pointer SANITIZERS=-fsanitize=address -fno-omit-frame-pointer
CFLAGS=-Wall -Wextra -Werror -ggdb $(SANITIZERS) -I mlx CFLAGS=-Wall -Wextra -Werror -g $(SANITIZERS) -I mlx
SOURCEFILES=src/main.c \ SOURCEFILES=src/main.c \
src/map/map_checker.c \ src/map/map_checker.c \
src/map/checkers.c \ src/map/checkers.c \
src/map/setters.c \ src/map/setters.c \
src/utils/frees.c src/utils/frees.c \
src/map/forbidden_characters.c
OBJECTS=$(patsubst src/%.c,objects/%.o,$(SOURCEFILES)) OBJECTS=$(patsubst src/%.c,objects/%.o,$(SOURCEFILES))
OBJDIR=objects OBJDIR=objects
NAME=cub3d NAME=cub3d

View file

@ -10,10 +10,7 @@ D - porte tel que defini dans le sujet
d - porte a points (cod) d - porte a points (cod)
Z - zombie Z - zombie
z - spawner zombie (porte a six coups pour les zombies) z - spawner zombie (porte a six coups pour les zombies)
S - source de son s - source de son
M - boite magique M - boite magique
## idées (avec symboles si possible)
C - arme dessinée sur le mur
faire un systeme de "cheats" soit par un menu de debug soit par une ligne de commande intégrée dans le jeu faire un systeme de "cheats" soit par un menu de debug soit par une ligne de commande intégrée dans le jeu

View file

@ -1,5 +1,5 @@
CC=cc CC=cc
CFLAGS=-Wall -Wextra -Werror -c CFLAGS=-Wall -Wextra -Werror -g -c
SOURCEFILES=src/str/ft_atoi.c src/mem/ft_bzero.c src/mem/ft_calloc.c src/cond/ft_isalnum.c \ SOURCEFILES=src/str/ft_atoi.c src/mem/ft_bzero.c src/mem/ft_calloc.c src/cond/ft_isalnum.c \
src/cond/ft_isalpha.c src/cond/ft_isascii.c src/cond/ft_isdigit.c \ src/cond/ft_isalpha.c src/cond/ft_isascii.c src/cond/ft_isdigit.c \
src/cond/ft_isprint.c src/str/ft_itoa.c src/lst/ft_lstadd_back_bonus.c \ src/cond/ft_isprint.c src/str/ft_itoa.c src/lst/ft_lstadd_back_bonus.c \

View file

@ -0,0 +1,22 @@
NO ./path_to_the_north_texture
SO ./path_to_the_south_texture
WE ./path_to_the_west_texture
EA ./path_to_the_east_texture
F 220,100,0
C 225,30,0
1111111111111111111111111
100000000011000Z000000001
1011000001110000000000001
1001000000d000z0000000001
111111111011000001110000000000001
10000000001100000111011111D111111
11110111111111011100000010001
11110111111111011101010010001
110000001101010111M0000010001
10000000s00000001100000010001
10000000000000001101010010001
11000001110101011111011110N0111
11110111 1110101 101111010001
11111111 1111111 111111111111

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */ /* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */ /* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */
/* Updated: 2025/06/30 16:12:19 by tchampio ### ########.fr */ /* Updated: 2025/07/02 15:32:23 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -80,6 +80,14 @@ void draw_map(t_mapdata *map, t_mlx_data *data)
{ {
if (map->map[i][j] == '1') if (map->map[i][j] == '1')
draw_2d_wall(map->f_color, data, 20, 20 * j, 20 * i); draw_2d_wall(map->f_color, data, 20, 20 * j, 20 * i);
else if (map->map[i][j] == 'Z' || map->map[i][j] == 'z')
draw_2d_wall(0x0008D9D6, data, 20, 20 * j, 20 * i);
else if (map->map[i][j] == 'D' || map->map[i][j] == 'd')
draw_2d_wall(0x00FF2E63, data, 20, 20 * j, 20 * i);
else if (map->map[i][j] == 's')
draw_2d_wall(0x00E84545, data, 20, 20 * j, 20 * i);
else if (map->map[i][j] == 'M')
draw_2d_wall(0x00F4CE14, data, 20, 20 * j, 20 * i);
else if (ft_strchr("NSEW", map->map[i][j])) else if (ft_strchr("NSEW", map->map[i][j]))
draw_2d_wall(0x00FF0000, data, 20, 20 * j, 20 * i); draw_2d_wall(0x00FF0000, data, 20, 20 * j, 20 * i);
j++; j++;
@ -107,7 +115,7 @@ int main(int argc, char **argv)
mlx_key_hook(data.mlx_win, key_destroy, &data); mlx_key_hook(data.mlx_win, key_destroy, &data);
mlx_put_image_to_window(data.mlx, data.mlx_win, data.mlx_data->img, 0, 0); mlx_put_image_to_window(data.mlx, data.mlx_win, data.mlx_data->img, 0, 0);
#ifdef BONUS #ifdef BONUS
mlx_string_put(data.mlx, data.mlx_win, 100, 100, 0x00FFFFFF, "compiled with bonuses"); mlx_string_put(data.mlx, data.mlx_win, 10, 10, 0x00FFFFFF, "compiled with bonuses");
#endif #endif
mlx_loop(data.mlx); mlx_loop(data.mlx);
} }

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */ /* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/06/21 19:29:45 by tchampio #+# #+# */ /* Created: 2025/06/21 19:29:45 by tchampio #+# #+# */
/* Updated: 2025/06/21 19:32:04 by tchampio ### ########.fr */ /* Updated: 2025/07/02 10:38:16 by tchampio ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -108,20 +108,3 @@ bool check_bare_minimum(t_mapdata *map)
return (true); return (true);
return (false); return (false);
} }
bool has_forbidden_characters(char *line)
{
static const char *allowedchars = " 10NSEW\n";
size_t strsize;
int i;
strsize = ft_strlen(line);
i = 0;
while (i < (int)strsize)
{
if (!ft_strchr(allowedchars, line[i]))
return (true);
i++;
}
return (false);
}

View file

@ -0,0 +1,55 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* forbidden_characters.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/06/30 17:19:16 by tchampio #+# #+# */
/* Updated: 2025/07/02 15:33:37 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../includes/libft.h"
#include "../../includes/maputils.h"
#ifdef BONUS
bool has_forbidden_characters(char *line)
{
static const char *allowedchars = " 10NSEWDdZzsM\n";
size_t strsize;
int i;
strsize = ft_strlen(line);
i = 0;
while (i < (int)strsize)
{
if (!ft_strchr(allowedchars, line[i]))
return (true);
i++;
}
return (false);
}
#else
bool has_forbidden_characters(char *line)
{
static const char *allowedchars = " 10NSEW\n";
size_t strsize;
int i;
strsize = ft_strlen(line);
i = 0;
while (i < (int)strsize)
{
if (!ft_strchr(allowedchars, line[i]))
return (true);
i++;
}
return (false);
}
#endif