blob: cc41955ee6aa30a492e75c1a707f5a6cb42ba0ef (
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
|
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_get_player_spawn.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2020/02/02 19:07:18 by rbousset #+# ## ## #+# */
/* Updated: 2020/02/02 19:07:19 by rbousset ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
static uint8_t
ft_get_view_side(char c)
{
if (c == 'N')
return (1);
else if (c == 'E')
return (2);
else if (c == 'S')
return (3);
else if (c == 'W')
return (4);
return (1);
}
void
ft_get_player_spawn(t_player *plist, t_cub *clist)
{
size_t x;
size_t y;
x = 1;
y = 1;
while (clist->map[y])
{
while (clist->map[y][x])
{
if (ft_ischarset("NSEW", clist->map[y][x]))
{
plist->pos_x = x;
plist->pos_y = y;
plist->view_side = ft_get_view_side(clist->map[y][x]);
return ;
}
x++;
}
x = 1;
y++;
}
}
|