#include "fdf.h"

/*
** U -> up wiew
** I -> isometric original view
** O -> increase altitude
** P -> decrease altitude
** F -> fit to window
** C -> center
*/
void	keypress_more(int keycode, t_fdf *fdf)
{
	if (keycode == A)
		fdf->zoom += 1;
	else if (keycode == W)
		fdf->zoom -= 1;
	else if (keycode == U)
	{
		fdf->rot_x = 0;
		fdf->rot_y = 0;
	}
	else if (keycode == I)
	{
		fdf->rot_x = -45;
		fdf->rot_y = -35;
		fdf->mov_x = (fdf->win_size_x - fdf->map_size_x) / 2;
		fdf->mov_y = (fdf->win_size_y - fdf->map_size_y) / 2;
		fdf->zoom = 0;
	}
	else if (keycode == O)
		fdf->altitude++;
	else if (keycode == P)
		if (fdf->altitude > 1)
			fdf->altitude--;
}

/*
** Q -> move left
** D -> move right
** Z -> move up
** S -> move down
** A -> zoom
** W -> unzoom
*/
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
		keypress_more(keycode, fdf);
	draw_image(fdf);
	return (0);
}
