15static char *get_file_contents(
int fd)
23 line = get_next_line(fd);
26 if (file_contents == NULL)
27 file_contents = ft_strjoin(
"", line);
30 temp = ft_strjoin(file_contents, line);
35 if (file_contents == NULL)
37 line = get_next_line(fd);
39 return (file_contents);
42static char *read_cubfile(
char *filepath)
47 fd = open(filepath, O_RDONLY);
50 ft_eprintf(
"%s%s\n", ERR_PROMPT, EMSG_OPEN_FAILED);
53 file_contents = get_file_contents(fd);
54 if (file_contents == NULL)
56 ft_eprintf(
"%s%s\n", ERR_PROMPT, EMSG_READ_FAILED);
60 return (file_contents);
63static void init_frame(
t_game *game)
68 frame->map = (
t_map *)&game->map;
69 frame->img_3d = (
t_img *)&game->img_3d;
70 frame->texture = (
t_texture *)&game->texture;
71 frame->player = (
t_player *)&game->player;
75int init_cub_contents(
t_game *game,
char *filename)
81 file_contents = read_cubfile(filename);
82 if (file_contents == NULL)
83 return (EXIT_FAILURE);
86 status = parse_cubfile(&parse, game, (
const char *)file_contents);
89 if (status != EXIT_SUCCESS)
90 return (EXIT_FAILURE);
91 return (EXIT_SUCCESS);
single still image for render_frame
3D or 2D or Texture image