-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprep.c
56 lines (52 loc) · 1.67 KB
/
prep.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* prep.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gsferopo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/31 16:01:59 by gsferopo #+# #+# */
/* Updated: 2017/08/28 09:38:53 by gsferopo ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void map_alloc(t_proc *a)
{
char *line;
char **split;
int y_fd;
int x_fd;
int y;
y_fd = open(a->file_name, O_RDONLY);
x_fd = open(a->file_name, O_RDONLY);
while (get_next_line(y_fd, &line) == 1)
{
a->size_y++;
free(line);
}
a->m = (int **)malloc(sizeof(int *) * a->size_y);
get_next_line(x_fd, &line);
split = ft_strnsplit(line, ' ', &(a->size_x));
while (*split)
free(*split++);
free(line);
y = a->size_y;
while (--y >= 0)
(a->m[y] = (int *)malloc(sizeof(int) * a->size_x));
close(y_fd);
close(x_fd);
}
void prep_var(t_proc *a, char *av)
{
map_alloc(a);
a->zoom = 14;
if (a->size_x > 150 || a->size_y > 150)
a->zoom = 3;
a->x = 0;
a->y = 0;
a->rot = 45;
a->indx = 300;
a->indy = 100;
a->mlx = mlx_init();
a->win = mlx_new_window(a->mlx, 800, 800, av);
}