1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_treat_args.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:29:00 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:29:08 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <mlx.h>
#include <stddef.h>
#include <stdint.h>
#include <unistd.h>
uint8_t
ft_check_map_arg(int argc, const char *argv[])
{
(void)argv;
if (argc < 2)
{
ft_dprintf(STDERR_FILENO, "Error\n\033[1;31mNo map selected\n\033[0m");
return (FT_RET_BAD_ARGV);
}
return (0);
}
static void
ft_init_macos_img(t_cub *clist)
{
if (FT_OS == 1)
{
clist->img.img = mlx_new_image(clist->wlist.wlx,
clist->wlist.x_size, clist->wlist.y_size);
clist->img.ptr = mlx_get_data_addr(clist->img.img, &clist->img.bpp,
&clist->img.sizeline, &clist->img.endian);
}
}
uint8_t
ft_use_args(int argc, const char *argv[], t_cub *clist)
{
if (argc < 3)
{
if (ft_init_winptr(clist) < 0)
return (ft_exit(FT_RET_FAILED_MLX, clist));
ft_wall_tex_init(clist);
ft_weap_tex_init(clist);
ft_num_tex_init(clist);
ft_init_macos_img(clist);
ft_draw_scene(clist);
if (clist->mlist.ismusic)
ft_enable_music(clist);
ft_hooks_and_loops(&clist->wlist, clist);
}
else if (argc == 3 && !ft_strncmp("--save", argv[2], 7))
{
ft_draw_scene_bmp(clist);
return (ft_exit(FT_RET_FINE, clist));
}
else
return (ft_error(FT_RET_BAD_ARGV, FT_ERR_ARGV, clist));
return (FT_RET_FINE);
}
|