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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tex_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fmoenne- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:43:55 by fmoenne- #+# #+# */
/* Updated: 2020/02/14 17:43:56 by fmoenne- ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
#include <mlx.h>
/*
** tlist[] index summary
** ---------------------
** 0: no
** 1: so
** 2: ea
** 3: we
** 4: sprite 2
** 5: new level door
** 6: floor
** 7: ceil / skybox
** 8: sprite 3
** 9: sprite 4
** 10: sprite 5
** 11: sprite 6
** 12: sprite 7
** 13: sprite 8
** 14: sprite 9
** 15: trap
** 16: HUD back
** 17: heal pack
** 18: weapon one sprite
** 19: weapon two sprite
*/
static void
ft_init_numbers(t_cub *cl)
{
cl->tnum[0].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_ZER_PATH, &cl->tnum[0].img_w, &cl->tnum[0].img_h);
cl->tnum[0].ptr = mlx_get_data_addr(cl->tnum[0].img,
&cl->tnum[0].bpp, &cl->tnum[0].sizeline, &cl->tnum[0].endian);
cl->tnum[1].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_ONE_PATH, &cl->tnum[1].img_w, &cl->tnum[1].img_h);
cl->tnum[1].ptr = mlx_get_data_addr(cl->tnum[1].img,
&cl->tnum[1].bpp, &cl->tnum[1].sizeline, &cl->tnum[1].endian);
cl->tnum[2].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_TWO_PATH, &cl->tnum[2].img_w, &cl->tnum[2].img_h);
cl->tnum[2].ptr = mlx_get_data_addr(cl->tnum[2].img,
&cl->tnum[2].bpp, &cl->tnum[2].sizeline, &cl->tnum[2].endian);
cl->tnum[3].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_THR_PATH, &cl->tnum[3].img_w, &cl->tnum[3].img_h);
cl->tnum[3].ptr = mlx_get_data_addr(cl->tnum[3].img,
&cl->tnum[3].bpp, &cl->tnum[3].sizeline, &cl->tnum[3].endian);
cl->tnum[4].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_FOU_PATH, &cl->tnum[4].img_w, &cl->tnum[4].img_h);
cl->tnum[4].ptr = mlx_get_data_addr(cl->tnum[4].img,
&cl->tnum[4].bpp, &cl->tnum[4].sizeline, &cl->tnum[4].endian);
cl->tnum[5].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_FIV_PATH, &cl->tnum[5].img_w, &cl->tnum[5].img_h);
cl->tnum[5].ptr = mlx_get_data_addr(cl->tnum[5].img,
&cl->tnum[5].bpp, &cl->tnum[5].sizeline, &cl->tnum[5].endian);
cl->tnum[6].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_SIX_PATH, &cl->tnum[6].img_w, &cl->tnum[6].img_h);
cl->tnum[6].ptr = mlx_get_data_addr(cl->tnum[6].img,
&cl->tnum[6].bpp, &cl->tnum[6].sizeline, &cl->tnum[6].endian);
cl->tnum[7].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_SEV_PATH, &cl->tnum[7].img_w, &cl->tnum[7].img_h);
cl->tnum[7].ptr = mlx_get_data_addr(cl->tnum[7].img,
&cl->tnum[7].bpp, &cl->tnum[7].sizeline, &cl->tnum[7].endian);
cl->tnum[8].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_EIG_PATH, &cl->tnum[8].img_w, &cl->tnum[8].img_h);
cl->tnum[8].ptr = mlx_get_data_addr(cl->tnum[8].img,
&cl->tnum[8].bpp, &cl->tnum[8].sizeline, &cl->tnum[8].endian);
cl->tnum[9].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_NIN_PATH, &cl->tnum[9].img_w, &cl->tnum[9].img_h);
cl->tnum[9].ptr = mlx_get_data_addr(cl->tnum[9].img,
&cl->tnum[9].bpp, &cl->tnum[9].sizeline, &cl->tnum[9].endian);
cl->tnum[10].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_PER_PATH, &cl->tnum[10].img_w, &cl->tnum[10].img_h);
cl->tnum[10].ptr = mlx_get_data_addr(cl->tnum[10].img,
&cl->tnum[10].bpp, &cl->tnum[10].sizeline, &cl->tnum[10].endian);
}
static void
ft_next_sprite_init(t_cub *cl)
{
uint8_t i;
i = 1;
while (cl->mlist.sprite_path[i][0])
{
cl->tlist[i + 7].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.sprite_path[i], &cl->tlist[i + 7].img_w,
&cl->tlist[i + 7].img_h);
cl->tlist[i + 7].ptr = mlx_get_data_addr(cl->tlist[i + 7].img,
&cl->tlist[i + 7].bpp, &cl->tlist[i + 7].sizeline,
&cl->tlist[i + 7].endian);
i++;
}
}
static void
ft_wall_tex_init_norme_bis(t_cub *cl)
{
if (cl->mlist.isskybox)
{
cl->tlist[7].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.skybox_path, &cl->tlist[7].img_w, &cl->tlist[7].img_h);
cl->tlist[7].ptr = mlx_get_data_addr(cl->tlist[7].img,
&cl->tlist[7].bpp, &cl->tlist[7].sizeline, &cl->tlist[7].endian);
}
else if (cl->mlist.isctex)
{
cl->tlist[7].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.ce_tex_path, &cl->tlist[7].img_w, &cl->tlist[7].img_h);
cl->tlist[7].ptr = mlx_get_data_addr(cl->tlist[7].img,
&cl->tlist[7].bpp, &cl->tlist[7].sizeline, &cl->tlist[7].endian);
}
cl->tlist[16].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_HUD_BACK_PATH, &cl->tlist[16].img_w, &cl->tlist[16].img_h);
cl->tlist[16].ptr = mlx_get_data_addr(cl->tlist[16].img,
&cl->tlist[16].bpp, &cl->tlist[16].sizeline, &cl->tlist[16].endian);
cl->tlist[18].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_WEAPON_ONE_SPR_PATH, &cl->tlist[18].img_w, &cl->tlist[18].img_h);
cl->tlist[18].ptr = mlx_get_data_addr(cl->tlist[18].img,
&cl->tlist[18].bpp, &cl->tlist[18].sizeline, &cl->tlist[18].endian);
cl->tlist[19].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_WEAPON_TWO_SPR_PATH, &cl->tlist[19].img_w, &cl->tlist[19].img_h);
cl->tlist[19].ptr = mlx_get_data_addr(cl->tlist[19].img,
&cl->tlist[19].bpp, &cl->tlist[19].sizeline, &cl->tlist[19].endian);
ft_init_numbers(cl);
cl->walltexgood = 1;
if (cl->mlist.sprite_var > 1)
ft_next_sprite_init(cl);
}
static void
ft_wall_tex_init_norme(t_cub *cl)
{
if (cl->mlist.isnlvl)
{
cl->tlist[5].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.nl_tex_path, &cl->tlist[5].img_w, &cl->tlist[5].img_h);
cl->tlist[5].ptr = mlx_get_data_addr(cl->tlist[5].img,
&cl->tlist[5].bpp, &cl->tlist[5].sizeline, &cl->tlist[5].endian);
}
if (cl->mlist.isftex)
{
cl->tlist[6].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.fl_tex_path, &cl->tlist[6].img_w, &cl->tlist[6].img_h);
cl->tlist[6].ptr = mlx_get_data_addr(cl->tlist[6].img,
&cl->tlist[6].bpp, &cl->tlist[6].sizeline, &cl->tlist[6].endian);
}
if (cl->mlist.istraps)
{
cl->tlist[15].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.traps_path, &cl->tlist[15].img_w, &cl->tlist[15].img_h);
cl->tlist[15].ptr = mlx_get_data_addr(cl->tlist[15].img,
&cl->tlist[15].bpp, &cl->tlist[15].sizeline, &cl->tlist[15].endian);
}
if (cl->mlist.isheals)
{
cl->tlist[17].img = mlx_xpm_file_to_image(cl->wlist.wlx,
FT_HEAL_PACK_PATH, &cl->tlist[17].img_w, &cl->tlist[17].img_h);
cl->tlist[17].ptr = mlx_get_data_addr(cl->tlist[17].img,
&cl->tlist[17].bpp, &cl->tlist[17].sizeline, &cl->tlist[17].endian);
}
ft_wall_tex_init_norme_bis(cl);
}
void
ft_wall_tex_init(t_cub *cl)
{
cl->tlist[0].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.no_tex_path, &cl->tlist[0].img_w, &cl->tlist[0].img_h);
cl->tlist[0].ptr = mlx_get_data_addr(cl->tlist[0].img,
&cl->tlist[0].bpp, &cl->tlist[0].sizeline, &cl->tlist[0].endian);
cl->tlist[1].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.so_tex_path, &cl->tlist[1].img_w, &cl->tlist[1].img_h);
cl->tlist[1].ptr = mlx_get_data_addr(cl->tlist[1].img,
&cl->tlist[1].bpp, &cl->tlist[1].sizeline, &cl->tlist[1].endian);
cl->tlist[2].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.ea_tex_path, &cl->tlist[2].img_w, &cl->tlist[2].img_h);
cl->tlist[2].ptr = mlx_get_data_addr(cl->tlist[2].img,
&cl->tlist[2].bpp, &cl->tlist[2].sizeline, &cl->tlist[2].endian);
cl->tlist[3].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.we_tex_path, &cl->tlist[3].img_w, &cl->tlist[3].img_h);
cl->tlist[3].ptr = mlx_get_data_addr(cl->tlist[3].img,
&cl->tlist[3].bpp, &cl->tlist[3].sizeline, &cl->tlist[3].endian);
cl->tlist[4].img = mlx_xpm_file_to_image(cl->wlist.wlx,
cl->mlist.sprite_path[0], &cl->tlist[4].img_w, &cl->tlist[4].img_h);
cl->tlist[4].ptr = mlx_get_data_addr(cl->tlist[4].img,
&cl->tlist[4].bpp, &cl->tlist[4].sizeline, &cl->tlist[4].endian);
ft_wall_tex_init_norme(cl);
}
|