From 5c1d469cac6026450600cab2514fba0d2c987d4d Mon Sep 17 00:00:00 2001 From: Theo Champion Date: Wed, 2 Jul 2025 15:35:05 +0200 Subject: [PATCH] Started bonus part - added bonus rules in makefile - added a BONUS define for bonus - added a conditional check for characters --- Makefile | 5 ++- README.md | 5 +-- libft/Makefile | 2 +- ressources/good_maps/testmap_bonus.cub | 22 +++++++++++ src/main.c | 12 +++++- src/map/checkers.c | 19 +-------- src/map/forbidden_characters.c | 55 ++++++++++++++++++++++++++ 7 files changed, 93 insertions(+), 27 deletions(-) create mode 100644 ressources/good_maps/testmap_bonus.cub create mode 100644 src/map/forbidden_characters.c diff --git a/Makefile b/Makefile index 98c0e00..5089f30 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ CC=cc 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 \ src/map/map_checker.c \ src/map/checkers.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)) OBJDIR=objects NAME=cub3d diff --git a/README.md b/README.md index 163d008..f344ea9 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,7 @@ D - porte tel que defini dans le sujet d - porte a points (cod) Z - zombie z - spawner zombie (porte a six coups pour les zombies) -S - source de son +s - source de son 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 diff --git a/libft/Makefile b/libft/Makefile index b219429..cd7a071 100644 --- a/libft/Makefile +++ b/libft/Makefile @@ -1,5 +1,5 @@ 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 \ 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 \ diff --git a/ressources/good_maps/testmap_bonus.cub b/ressources/good_maps/testmap_bonus.cub new file mode 100644 index 0000000..4769d16 --- /dev/null +++ b/ressources/good_maps/testmap_bonus.cub @@ -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 diff --git a/src/main.c b/src/main.c index 7b1435c..5a763d3 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: tchampio map[i][j] == '1') 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])) draw_2d_wall(0x00FF0000, data, 20, 20 * j, 20 * i); j++; @@ -107,7 +115,7 @@ int main(int argc, char **argv) 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); #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 mlx_loop(data.mlx); } diff --git a/src/map/checkers.c b/src/map/checkers.c index 6c4ec34..402fd20 100644 --- a/src/map/checkers.c +++ b/src/map/checkers.c @@ -6,7 +6,7 @@ /* 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 (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); -} diff --git a/src/map/forbidden_characters.c b/src/map/forbidden_characters.c new file mode 100644 index 0000000..9004b69 --- /dev/null +++ b/src/map/forbidden_characters.c @@ -0,0 +1,55 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* forbidden_characters.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tchampio