map fits window
This commit is contained in:
@@ -1,34 +1,5 @@
|
||||
#include "fdf.h"
|
||||
|
||||
// add "print_keycode(keycode);" at begining to print keycode
|
||||
int keypress(int keycode, t_fdf *fdf)
|
||||
{
|
||||
if (keycode == ESCAPE)
|
||||
shut_down(fdf);
|
||||
else if (keycode == LEFT)
|
||||
(fdf->rot_x) += 1;
|
||||
else if (keycode == RIGHT)
|
||||
(fdf->rot_x) -= 1;
|
||||
else if (keycode == UP)
|
||||
(fdf->rot_y) += 1;
|
||||
else if (keycode == DOWN)
|
||||
(fdf->rot_y) -= 1;
|
||||
else if (keycode == Q)
|
||||
(fdf->mov_x) -= 6;
|
||||
else if (keycode == D)
|
||||
(fdf->mov_x) += 6;
|
||||
else if (keycode == Z)
|
||||
(fdf->mov_y) -= 6;
|
||||
else if (keycode == S)
|
||||
(fdf->mov_y) += 6;
|
||||
else if (keycode == A)
|
||||
(fdf->zoom) += 6;
|
||||
else if (keycode == W)
|
||||
(fdf->zoom) -= 6;
|
||||
draw_image(fdf);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
** int[0] = x, int[1] = y, int[2] = z
|
||||
** quick explanation :
|
||||
@@ -39,7 +10,7 @@ int keypress(int keycode, t_fdf *fdf)
|
||||
** z changes according to zoom :
|
||||
** z += (z * fdf->zoom) / fdf->offset;
|
||||
** deplacement :
|
||||
** point[0] += fdf->margin + fdf->mov_x;
|
||||
** point[0] += fdf->mov_x;
|
||||
** center zoom :
|
||||
** point[0] -= ((fdf->map_size_x / 2) / fdf->offset) * fdf->zoom;
|
||||
** center after 3d rotation :
|
||||
@@ -62,8 +33,8 @@ int *new_coordinates(t_fdf *fdf, int i, int j)
|
||||
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);
|
||||
point[0] += fdf->margin + fdf->mov_x;
|
||||
point[1] += fdf->margin + fdf->mov_y;
|
||||
point[0] += fdf->mov_x;
|
||||
point[1] += fdf->mov_y;
|
||||
point[0] -= ((fdf->map_size_x / 2) / fdf->offset) * fdf->zoom;
|
||||
point[1] -= ((fdf->map_size_y / 2) / fdf->offset) * fdf->zoom;
|
||||
point[0] += (fdf->map_size_x + fdf->zoom * fdf->map_width) / 2;
|
||||
@@ -72,13 +43,6 @@ int *new_coordinates(t_fdf *fdf, int i, int j)
|
||||
return (point);
|
||||
}
|
||||
|
||||
int print_keycode(int keycode)
|
||||
{
|
||||
ft_putnbr(keycode);
|
||||
ft_putchar(' ');
|
||||
return (0);
|
||||
}
|
||||
|
||||
void position_state(t_fdf *fdf)
|
||||
{
|
||||
char *position;
|
||||
@@ -101,3 +65,12 @@ void position_state(t_fdf *fdf)
|
||||
mlx_string_put(fdf->mlx_ptr, fdf->win_ptr, x, y, 0xffffff, position);
|
||||
free(position);
|
||||
}
|
||||
|
||||
/*
|
||||
** int print_keycode(int keycode)
|
||||
** {
|
||||
** ft_putnbr(keycode);
|
||||
** ft_putchar(' ');
|
||||
** return (0);
|
||||
** }
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user