-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_init_map.c
74 lines (67 loc) · 1.71 KB
/
ft_init_map.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_init_map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mgaspail <mgaspail@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/01/18 15:40:51 by mgaspail #+# #+# */
/* Updated: 2014/01/18 15:45:13 by mgaspail ### ########.fr */
/* */
/* ************************************************************************** */
#include "wolf.h"
#include <stdlib.h>
void ft_copy_tab(int **map, t_data *e)
{
int i;
int j;
i = 0;
e->map_1 = (int**)malloc(sizeof(e->map_1) * (26));
while (i != 26)
{
j = 0;
e->map_1[i] = (int*)malloc(sizeof(e->map_1) * (26));
while (j != 26)
{
e->map_1[i][j] = map[i][j];
j++;
}
i++;
}
}
int get_start_pos(int **map, t_data *e)
{
int i;
int j;
i = 0;
while (i < 26)
{
j = 0;
while (j < 26)
{
if (map[i][j] == -3)
{
e->posx = i;
e->posy = j;
}
j++;
}
i++;
}
return (0);
}
void change_map(int override, t_data *e)
{
static int number = -1;
number++;
if (override != 0)
number = override;
if (e->map_1 != NULL)
free(e->map_1);
ft_copy_tab(e->map[number % 4], e);
get_start_pos(e->map[number % 4], e);
e->planex = 0;
e->dirx = -1;
e->diry = 0;
e->planey = 0.66;
}