a la norme et sans leaks, manque le parsing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "fdf.h"
|
||||
|
||||
// add "print_keycode(keycode);" at begining to print keycode
|
||||
int keypress(int keycode, t_fdf *fdf)
|
||||
int keypress(int keycode, t_fdf *fdf)
|
||||
{
|
||||
if (keycode == ESCAPE)
|
||||
shut_down(fdf);
|
||||
@@ -32,43 +32,36 @@ int keypress(int keycode, t_fdf *fdf)
|
||||
// return an int[3] : int[0] = x, int[1] = y, int[2] = z
|
||||
int *new_coordinates(t_fdf *fdf, int i, int j)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
int *point;
|
||||
|
||||
point = ft_calloc(3, sizeof(int));
|
||||
// pre zoom
|
||||
x = i * (fdf->offset + fdf->zoom);
|
||||
y = j * (fdf->offset + fdf->zoom);
|
||||
// pre center
|
||||
x -= (fdf->map_size_x + fdf->zoom * fdf->map_width) / 2;
|
||||
y -= (fdf->map_size_y + fdf->zoom * fdf->map_height) / 2;
|
||||
// rotation
|
||||
z = fdf->map[j][i] * fdf->altitude;
|
||||
z += (z * fdf->zoom) / fdf->offset;
|
||||
point[0] = x * cos(fdf->rad_x) + y * sin(fdf->rad_x);
|
||||
point[1] = y * cos(fdf->rad_x) - x * sin(fdf->rad_x);
|
||||
point[1] = point[1] * cos(fdf->rad_y) - -z * sin(fdf->rad_y);
|
||||
// deplacements
|
||||
point[0] += fdf->margin + fdf->mov_x;
|
||||
point[1] += fdf->margin + fdf->mov_y;
|
||||
// post zoom
|
||||
point[0] -= ((fdf->map_size_x / 2) / fdf->offset) * fdf->zoom;
|
||||
point[1] -= ((fdf->map_size_y / 2) / fdf->offset) * fdf->zoom;
|
||||
// post center
|
||||
point[0] += (fdf->map_size_x + fdf->zoom * fdf->map_width) / 2;
|
||||
point[1] += (fdf->map_size_y + fdf->zoom * fdf->map_height) / 2;
|
||||
|
||||
point[2] = z;
|
||||
return (point);
|
||||
}
|
||||
|
||||
int print_keycode(int keycode)
|
||||
int print_keycode(int keycode)
|
||||
{
|
||||
ft_putnbr(keycode);
|
||||
ft_putchar(' ');
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void rotation_state(t_fdf *fdf)
|
||||
@@ -79,8 +72,9 @@ void rotation_state(t_fdf *fdf)
|
||||
|
||||
x = fdf->img_size_x - 10;
|
||||
y = fdf->img_size_y - 10;
|
||||
position = ft_strjoin(ft_itoa(fdf->rot_x), ft_strdup(" | "));
|
||||
position = ft_strjoin(position, ft_itoa(fdf->rot_y));
|
||||
position = ft_strjoinfree(ft_itoa(fdf->rot_x), ft_strdup(" | "));
|
||||
position = ft_strjoinfree(position, ft_itoa(fdf->rot_y));
|
||||
x -= ft_strlen(position) * 6;
|
||||
mlx_string_put(fdf->mlx_ptr, fdf->win_ptr, x, y, 0xffffff, position);
|
||||
free(position);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user