aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-02-28 18:30:36 +0100
committerRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-02-28 18:30:36 +0100
commitc9b5e6dfdfc7d97183786279bbe68675a83d83f4 (patch)
treeb121c25d2fa56dc45331d952948bf9cea7a64e8b
parentIn progress (diff)
download42-cub3d-c9b5e6dfdfc7d97183786279bbe68675a83d83f4.tar.gz
42-cub3d-c9b5e6dfdfc7d97183786279bbe68675a83d83f4.tar.bz2
42-cub3d-c9b5e6dfdfc7d97183786279bbe68675a83d83f4.tar.xz
42-cub3d-c9b5e6dfdfc7d97183786279bbe68675a83d83f4.tar.zst
42-cub3d-c9b5e6dfdfc7d97183786279bbe68675a83d83f4.zip
In progress
Diffstat (limited to '')
-rw-r--r--Makefile2
-rw-r--r--inc/cub3d.h128
-rw-r--r--inc/cub3d_structs.h1
-rw-r--r--map/lvl_one.cub1
-rw-r--r--src/ft_exit.c1
-rw-r--r--src/ft_get_path_nl.c41
-rw-r--r--src/ft_get_tex.c2
-rw-r--r--src/ft_get_tex_nl.c41
-rw-r--r--src/ft_select_get.c4
9 files changed, 155 insertions, 66 deletions
diff --git a/Makefile b/Makefile
index 8540a0e..8f1dd65 100644
--- a/Makefile
+++ b/Makefile
@@ -178,7 +178,7 @@ fclean: clean
re: fclean all
#--------------------------------------------------------------------------------------------------#
run: all
- @./${NAME} "map/map_one.cub"
+ @./${NAME} "map/lvl_one.cub"
#--------------------------------------------------------------------------------------------------#
.PHONY: all clean clean fclean re run default
#============================================== EOF ===============================================#
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 5f1c6f8..41d669f 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -28,68 +28,70 @@
** 6: read error
*/
-int8_t ft_init_cub3d(t_cub **clist);
-t_map *ft_init_map(void);
-void ft_wall_tex_init(t_cub *clist);
-void ft_choose_tex(t_cub *clist);
-void ft_hooks_and_loops(t_win *wl, t_cub *cl);
-int ft_key_event(int keycode, t_cub *clist);
-int ft_click_close(int keycode, t_cub *clist);
-int ft_exit(uint8_t exit_code, t_cub *clist);
-void ft_draw_square(int a, int b, int rgb, t_cub *clist);
-void ft_parse_map(const char *map_path, t_cub *clist);
-int8_t ft_select_get(char **words, t_cub *clist);
-int8_t ft_get_screen_size(t_win *wlist);
-int8_t ft_get_res(char **words, t_cub *clist);
-int8_t ft_get_tex_no(char **words, t_cub *clist);
-int8_t ft_get_tex_so(char **words, t_cub *clist);
-int8_t ft_get_tex_ea(char **words, t_cub *clist);
-int8_t ft_get_tex_we(char **words, t_cub *clist);
-int8_t ft_get_sprite(char **words, t_cub *clist);
-int8_t ft_get_f_color(char **words, t_cub *clist);
-int8_t ft_get_c_color(char **words, t_cub *clist);
-int ft_get_map_first_line(char *line, t_cub *clist);
-int ft_get_map_core(int fd, t_cub *clist);
-void ft_get_player_spawn(t_player *plist, t_cub *clist);
-void ft_set_minimap_scale(t_cub *clist);
-int ft_check_missing(t_cub *clist);
-int8_t ft_check_map_line(char *line, uint8_t l, t_cub *clist);
-size_t ft_get_line_len(char *line);
-int ft_missing_error(const char *err, t_cub *clist);
-uint8_t ft_free_words(char **words);
-int ft_map_error(const char *errmsg, t_cub *clist);
-int ft_init_winlx(t_cub *clist);
-void ft_draw_scene(t_cub *clist);
-void ft_print_list(t_cub *clist);
-uint32_t ft_rgb_to_hex(t_rgb rgb);
-t_ray ft_init_s_ray(void);
-void ft_detect(t_cub *cl);
-int8_t ft_draw_verline(t_cub *cl, int32_t x,
- int32_t y1, int32_t y2);
-void ft_castray(t_cub *cl);
-void ft_draw_map(char **map, t_cub *clist);
-int ft_w_key(t_cub *clist);
-int ft_a_key(t_cub *clist);
-int ft_s_key(t_cub *clist);
-int ft_d_key(t_cub *clist);
-int ft_f1_key(t_cub *clist);
-int ft_left_key(t_cub *clist);
-int ft_right_key(t_cub *clist);
-int ft_key_release(int keycode, t_cub *clist);
-int8_t ft_check_ext(const char *filep, const char *ext);
-int32_t ft_convert_keycode(const int32_t tmp_code);
-int ft_key_loop(t_cub *cl);
-void ft_draw_circle(float a, float b,
- int32_t color, t_cub *cl);
-void ft_draw_texture(t_cub *cl, int x, int y, int tex_y);
-int8_t ft_check_not_found(const char *path);
-void ft_calc_tex(t_cub *clist);
-void ft_draw_hud(t_cub *clist);
-void ft_draw_life_bar(size_t map_w,
- const uint16_t scale,
- const int8_t life,
- t_cub *cl);
-void ft_music(t_cub *cl);
-void ft_draw_sprite(t_cub *cl, int i);
+int8_t ft_init_cub3d(t_cub **clist);
+t_map *ft_init_map(void);
+void ft_wall_tex_init(t_cub *clist);
+void ft_choose_tex(t_cub *clist);
+void ft_hooks_and_loops(t_win *wl, t_cub *cl);
+int ft_key_event(int keycode, t_cub *clist);
+int ft_click_close(int keycode, t_cub *clist);
+int ft_exit(uint8_t exit_code, t_cub *clist);
+void ft_draw_square(int a, int b, int rgb, t_cub *clist);
+void ft_parse_map(const char *map_path, t_cub *clist);
+int8_t ft_select_get(char **words, t_cub *clist);
+int8_t ft_get_screen_size(t_win *wlist);
+int8_t ft_get_res(char **words, t_cub *clist);
+int8_t ft_get_tex_no(char **words, t_cub *clist);
+int8_t ft_get_tex_so(char **words, t_cub *clist);
+int8_t ft_get_tex_ea(char **words, t_cub *clist);
+int8_t ft_get_tex_we(char **words, t_cub *clist);
+int8_t ft_get_sprite(char **words, t_cub *clist);
+int8_t ft_get_f_color(char **words, t_cub *clist);
+int8_t ft_get_c_color(char **words, t_cub *clist);
+int8_t ft_get_path_nl(char **words, t_cub *clist);
+int8_t ft_get_tex_nl(char **words, t_cub *clist);
+int ft_get_map_first_line(char *line, t_cub *clist);
+int ft_get_map_core(int fd, t_cub *clist);
+void ft_get_player_spawn(t_player *plist, t_cub *clist);
+void ft_set_minimap_scale(t_cub *clist);
+int ft_check_missing(t_cub *clist);
+int8_t ft_check_map_line(char *line, uint8_t l, t_cub *clist);
+size_t ft_get_line_len(char *line);
+int ft_missing_error(const char *err, t_cub *clist);
+uint8_t ft_free_words(char **words);
+int ft_map_error(const char *errmsg, t_cub *clist);
+int ft_init_winlx(t_cub *clist);
+void ft_draw_scene(t_cub *clist);
+void ft_print_list(t_cub *clist);
+uint32_t ft_rgb_to_hex(t_rgb rgb);
+t_ray ft_init_s_ray(void);
+void ft_detect(t_cub *cl);
+int8_t ft_draw_verline(t_cub *cl, int32_t x,
+ int32_t y1, int32_t y2);
+void ft_castray(t_cub *cl);
+void ft_draw_map(char **map, t_cub *clist);
+int ft_w_key(t_cub *clist);
+int ft_a_key(t_cub *clist);
+int ft_s_key(t_cub *clist);
+int ft_d_key(t_cub *clist);
+int ft_f1_key(t_cub *clist);
+int ft_left_key(t_cub *clist);
+int ft_right_key(t_cub *clist);
+int ft_key_release(int keycode, t_cub *clist);
+int8_t ft_check_ext(const char *filep, const char *ext);
+int32_t ft_convert_keycode(const int32_t tmp_code);
+int ft_key_loop(t_cub *cl);
+void ft_draw_circle(float a, float b,
+ int32_t color, t_cub *cl);
+void ft_draw_texture(t_cub *cl, int x, int y, int tex_y);
+int8_t ft_check_not_found(const char *path);
+void ft_calc_tex(t_cub *clist);
+void ft_draw_hud(t_cub *clist);
+void ft_draw_life_bar(size_t map_w,
+ const uint16_t scale,
+ const int8_t life,
+ t_cub *cl);
+void ft_music(t_cub *cl);
+void ft_draw_sprite(t_cub *cl, int i);
# endif
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index ebea0f7..33a291d 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -110,6 +110,7 @@ typedef struct s_map
char *ea_tex_path;
char *we_tex_path;
char *sprite_path;
+ char *nl_tex_path;
char *nlevel_path;
char *mapl;
char **map;
diff --git a/map/lvl_one.cub b/map/lvl_one.cub
index 627a774..9a3b511 100644
--- a/map/lvl_one.cub
+++ b/map/lvl_one.cub
@@ -10,6 +10,7 @@ C 50,100,200
F 50,190,124
L ./map/lvl_two.cub
+LT ./media/img/crapaud.xpm
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 L 0 0 1
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 97671d6..83e4b2e 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -25,6 +25,7 @@ static void
ft_memdel((void**)&clist->mlist->ea_tex_path);
ft_memdel((void**)&clist->mlist->we_tex_path);
ft_memdel((void**)&clist->mlist->sprite_path);
+ ft_memdel((void**)&clist->mlist->nl_tex_path);
ft_memdel((void**)&clist->mlist->nlevel_path);
ft_memdel((void**)&clist->mlist->mapl);
ft_free_words(clist->mlist->map);
diff --git a/src/ft_get_path_nl.c b/src/ft_get_path_nl.c
new file mode 100644
index 0000000..0b5e987
--- /dev/null
+++ b/src/ft_get_path_nl.c
@@ -0,0 +1,41 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_get_path_nl.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/28 18:30:18 by rbousset #+# #+# */
+/* Updated: 2020/02/28 18:30:19 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <cub3d.h>
+#include <stdint.h>
+
+int8_t
+ ft_get_path_nl(char **words, t_cub *clist)
+{
+ if (!(*words) || !(*(words + 1)) || (*(words + 2)))
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
+ return (-1);
+ }
+ if (ft_check_ext(*(words + 1), ".cub") < 0)
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM);
+ return (-1);
+ }
+ ft_memdel((void**)&clist->mlist->nlevel_path);
+ if (!(clist->mlist->nlevel_path = ft_strdup(*(words + 1))))
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
+ return (-1);
+ }
+ if (ft_check_not_found(clist->mlist->nlevel_path) < 0)
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_RD_NO);
+ return (-1);
+ }
+ return (0);
+}
diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c
index 1327d58..2611fef 100644
--- a/src/ft_get_tex.c
+++ b/src/ft_get_tex.c
@@ -12,7 +12,7 @@
#include <libft.h>
#include <cub3d.h>
-#include <stdlib.h>
+#include <stdint.h>
int8_t
ft_get_tex_no(char **words, t_cub *clist)
diff --git a/src/ft_get_tex_nl.c b/src/ft_get_tex_nl.c
new file mode 100644
index 0000000..e1ee5ce
--- /dev/null
+++ b/src/ft_get_tex_nl.c
@@ -0,0 +1,41 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_get_tex_nl.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/28 18:24:52 by rbousset #+# #+# */
+/* Updated: 2020/02/28 18:24:56 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <cub3d.h>
+#include <stdint.h>
+
+int8_t
+ ft_get_tex_nl(char **words, t_cub *clist)
+{
+ if (!(*words) || !(*(words + 1)) || (*(words + 2)))
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
+ return (-1);
+ }
+ if (ft_check_ext(*(words + 1), ".xpm") < 0)
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM);
+ return (-1);
+ }
+ ft_memdel((void**)&clist->mlist->nl_tex_path);
+ if (!(clist->mlist->nl_tex_path = ft_strdup(*(words + 1))))
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
+ return (-1);
+ }
+ if (ft_check_not_found(clist->mlist->nl_tex_path) < 0)
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_RD_NO);
+ return (-1);
+ }
+ return (0);
+}
diff --git a/src/ft_select_get.c b/src/ft_select_get.c
index 4b82430..b5df1bc 100644
--- a/src/ft_select_get.c
+++ b/src/ft_select_get.c
@@ -67,7 +67,7 @@ static int8_t
int8_t
ft_select_get(char **words, t_cub *clist)
{
- int8_t (*fun_ptr[8])(char**, t_cub*);
+ int8_t (*fun_ptr[10])(char**, t_cub*);
int8_t id;
fun_ptr[0] = ft_get_res;
@@ -78,6 +78,8 @@ int8_t
fun_ptr[5] = ft_get_sprite;
fun_ptr[6] = ft_get_f_color;
fun_ptr[7] = ft_get_c_color;
+ fun_ptr[8] = ft_get_path_nl;
+ fun_ptr[9] = ft_get_tex_nl;
if ((id = ft_get_id(words, clist)) == 12)
{
ft_free_words(words);