-
Notifications
You must be signed in to change notification settings - Fork 0
/
mlx_init.c
70 lines (65 loc) · 1.94 KB
/
mlx_init.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mlx_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hgrissen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 16:10:47 by hgrissen #+# #+# */
/* Updated: 2021/02/15 18:09:20 by hgrissen ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void canvas_init(void)
{
g_s_count = 0;
g_hmini = g_prm.h / MINI_MAP;
g_wmini = g_prm.w / MINI_MAP;
g_x = 1;
g_mlx.mlx = mlx_init();
g_mlx.mlx_win = mlx_new_window(g_mlx.mlx, g_prm.w, g_prm.h, "CUB3D");
g_img.img = mlx_new_image(g_mlx.mlx, g_prm.w, g_prm.h);
g_img.addr = mlx_get_data_addr(g_img.img, &g_img.bpp,
&g_img.ll, &g_img.end);
player_init();
}
void player_init(void)
{
g_post = 0;
g_damageable = 1;
g_dmg = 0;
g_healthmax = g_prm.w - (g_prm.w / 4) - 2 - ((g_prm.w / 4) + 2);
player_pos();
g_p.iscrouch = 0;
g_p.crouch = 0;
g_p.turndir = 0;
g_p.vir_dir = 0;
g_p.hor_dir = 0;
g_p.rotang = spawn_direction();
g_p.movespeed = PLAYER_MOVE_SPEED;
g_p.turnspeed = PLAYER_TURN_SPEED;
g_p.hlfpi = 0;
g_p.ismap = 0;
}
void player_pos(void)
{
int i;
int j;
i = 0;
while (i < g_prm.nwlcnt)
{
j = 0;
while (j < g_prm.lnglin)
{
if (is_player(g_prm.map[i][j]))
{
g_p.x = j * TILE_SIZE + (TILE_SIZE / 2);
g_p.y = i * TILE_SIZE + (TILE_SIZE / 2);
}
else if (g_prm.map[i][j] == '2')
g_s_count++;
j++;
}
i++;
}
}