-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_all_inputs.c
84 lines (75 loc) · 2.04 KB
/
get_all_inputs.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
82
83
84
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_all_inputs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rmurdoch <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/09 12:04:35 by rmurdoch #+# #+# */
/* Updated: 2018/01/09 12:04:43 by rmurdoch ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
void get_player(int *hx, int *hy)
{
char *line;
int p;
p = 111;
get_next_line(0, &line);
p = (ft_strsplit((const char *)line, ' ')[2][1] == '1') ? 111 : 120;
free(line);
if (p == 111)
{
*hx = 111;
*hy = 120;
}
if (p == 120)
{
*hx = 120;
*hy = 111;
}
}
void get_input(int *x, int *y)
{
char *line;
get_next_line(0, &line);
*x = ft_atoi(ft_strsplit((const char *)line, ' ')[1]);
*y = ft_atoi(ft_strsplit((const char *)line, ' ')[2]);
free(line);
}
char **get_map(int x, int y)
{
char **map;
char *line;
int cx;
cx = 0;
map = (char**)malloc((sizeof(char*) * (x + 1)));
get_next_line(0, &line);
free(line);
while (cx < x)
{
get_next_line(0, &line);
map[cx] = (char*)malloc((sizeof(char) * (y + 1)));
ft_strncpy(map[cx], ft_strsplit((const char *)line, ' ')[1], y + 1);
cx++;
free(line);
}
return (map);
}
char **get_piece(int px, int py)
{
char **piece;
char *line;
int cx;
cx = 0;
piece = (char**)malloc((sizeof(char*) * (px + 1)));
while (cx < px)
{
get_next_line(0, &line);
piece[cx] = (char*)malloc((sizeof(char) * (py + 1)));
ft_strcpy(piece[cx], line);
cx++;
ft_strdel(&line);
}
return (piece);
}