-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.c
81 lines (76 loc) · 2.17 KB
/
player.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
71
72
73
74
75
76
77
78
79
80
81
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* maps.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marza-ga <marza-ga-@student.42barcelo +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/04 21:59:00 by marza-ga #+# #+# */
/* Updated: 2022/03/04 22:17:00 by marza-ga ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3D.h"
void get_player_starting_angle2(t_mlx *mlx, char angle_char)
{
if (angle_char == 'E')
{
mlx->hero.vector_view.x = 1;
mlx->hero.vector_view.y = 0;
mlx->hero.angle_view = 0;
mlx->ray.planex = 0.0;
mlx->ray.planey = 0.66;
}
else if (angle_char == 'W')
{
mlx->hero.vector_view.x = -1;
mlx->hero.vector_view.y = 0;
mlx->hero.angle_view = 180;
mlx->ray.planex = 0.0;
mlx->ray.planey = -0.66;
}
}
void get_player_starting_angle(t_mlx *mlx, char angle_char)
{
if (angle_char == 'S')
{
mlx->hero.vector_view.x = 0;
mlx->hero.vector_view.y = 1;
mlx->hero.angle_view = 90;
mlx->ray.planex = -0.66;
mlx->ray.planey = 0.0;
}
else if (angle_char == 'N')
{
mlx->hero.vector_view.x = 0;
mlx->hero.vector_view.y = -1;
mlx->hero.angle_view = 270;
mlx->ray.planex = 0.66;
mlx->ray.planey = 0.0;
}
else
get_player_starting_angle2(mlx, angle_char);
}
void get_player_starting_map_data(t_mlx *mlx)
{
int x;
int y;
x = 0;
y = 0;
while (y < mlx->map_height)
{
while (x < mlx->map_width)
{
if (mlx->map[x][y] == 'N' || mlx->map[x][y] == 'E'
|| mlx->map[x][y] == 'W' || mlx->map[x][y] == 'S')
{
mlx->hero.pos.x = x + 0.5;
mlx->hero.pos.y = y + 0.5;
get_player_starting_angle(mlx, mlx->map[x][y]);
return ;
}
x++;
}
y++;
x = 0;
}
}