blob: 79b0d14364545370ecec46ef651113e413583b52 (
plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_init_lists.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:28:53 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:28:53 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <mlx.h>
#include <cub3d.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
t_rgb
ft_init_rgb(void)
{
t_rgb rgb;
rgb.r = -1;
rgb.g = -1;
rgb.b = -1;
return (rgb);
}
t_player
ft_init_player(void)
{
t_player plist;
plist.pos_x = 0;
plist.pos_y = 0;
plist.pos_z = 0;
plist.start_x = 0;
plist.start_y = 0;
plist.cam_x = 0;
plist.dir_x = -1;
plist.dir_y = 0;
plist.plane_x = 0;
plist.plane_y = 0.66;
plist.life = 100;
return (plist);
}
static int8_t
ft_init_win(t_win *wl)
{
if (!(wl->winptr = malloc(1)))
return (-1);
wl->inited = 0;
wl->x_size = 0;
wl->y_size = 0;
wl->x_max_size = 0;
wl->y_max_size = 0;
return (0);
}
static int8_t
ft_init_cub(t_cub *cl)
{
int8_t i;
if (ft_init_map(&cl->mlist) < 0)
return (-1);
cl->plist = ft_init_player();
ft_bzero(cl->errmsg, 40);
i = -1;
while (++i < 5)
cl->key_input[i] = -1;
cl->ishud = 0;
cl->isoldmus = 0;
cl->f_rgb = ft_init_rgb();
cl->c_rgb = ft_init_rgb();
cl->rlist = ft_init_s_ray();
cl->currlvl = 0;
cl->walltexgood = 0;
ft_init_funptr(cl);
ft_init_ref(cl);
return (0);
}
int8_t
ft_init_cub3d(t_cub *clist)
{
if (ft_init_cub(clist) < 0)
return (-1);
if (ft_init_win(&clist->wlist) < 0)
return (-1);
return (0);
}
|