-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_dot.c
123 lines (113 loc) · 2.84 KB
/
set_dot.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* set_dot.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ggiannit <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/21 18:34:42 by ggiannit #+# #+# */
/* Updated: 2023/02/07 17:25:00 by ggiannit ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
int ft_reset_minmax(t_map *map)
{
map->min_x = WIN_WIDE;
map->min_y = WIN_HEIGHT;
map->max_x = -1;
map->max_y = -1;
return (0);
}
void ft_fill_minmax(t_map *map, int the_x, int the_y)
{
if (the_x > map->max_x)
map->max_x = the_x;
if (the_x < map->min_x)
map->min_x = the_x;
if (the_y > map->max_y)
map->max_y = the_y;
if (the_y < map->min_y)
map->min_y = the_y;
}
void ft_set_dot_utils(t_map *map, void (*ft_vision)(t_dot *, t_map *),
int ky, int kx)
{
ft_rotate_z(&map->map[ky][kx], map);
ft_vision(&map->map[ky][kx], map);
map->map[ky][kx].x += map->zx;
map->map[ky][kx].y += map->zy;
ft_fill_minmax(map, (int) map->map[ky][kx].x,
(int) map->map[ky][kx].y);
}
int ft_set_dot(t_map *map, void (*ft_vision)(t_dot *, t_map *))
{
int a;
int b;
int kx;
int ky;
ky = ft_reset_minmax(map);
b = -1 * (map->y / 2);
while (ky < map->y)
{
kx = 0;
a = -1 * (map->x / 2);
while (kx < map->x)
{
map->map[ky][kx].x = (float)(a * map->zoom);
map->map[ky][kx].y = (float)(b * map->zoom);
ft_set_dot_utils(map, ft_vision, ky, kx);
kx++;
a++;
}
ky++;
b++;
}
return (0);
}
void ft_set_orto(t_map *map, int new_zx, int new_zy,
void (*ft_vision)(t_dot *, t_map *))
{
int a;
int b;
int kx;
int ky;
ky = ft_reset_minmax(map);
b = -1 * (map->y / 2);
while (ky < map->y)
{
kx = 0;
a = -1 * (map->x / 2);
while (kx < map->x)
{
map->map[ky][kx].x = (float)((a++) * map->zoom);
map->map[ky][kx].y = (float)(b * map->zoom);
ft_vision(&map->map[ky][kx], map);
map->map[ky][kx].x += new_zx;
map->map[ky][kx].y += new_zy;
ft_fill_minmax(map, (int) map->map[ky][kx].x,
(int) map->map[ky][kx].y);
kx++;
}
ky++;
b++;
}
}
/*void fdf_print_dot(t_map *maps, t_dot **mat)
{
fdf_print_dot(map, map->map);
int x;
int y;
x = 0;
y = 0;
while (y < maps->y)
{
while (x < maps->x)
{
ft_printf("%i,%i,%i ", mat[y][x].x, mat[y][x].y, mat[y][x].z);
x++;
}
ft_printf("\n");
y++;
x = 0;
}
}*/