/* ************************************************************************** */
/*                                                                            */
/*                                                        ::::::::            */
/*   hooks.c                                            :+:    :+:            */
/*                                                     +:+                    */
/*   By: qmennen <qmennen@student.codam.nl>           +#+                     */
/*                                                   +#+                      */
/*   Created: 2025/04/15 17:51:26 by qmennen       #+#    #+#                 */
/*   Updated: 2025/06/04 16:48:57 by whaffman      ########   odam.nl         */
/*                                                                            */
/* ************************************************************************** */

#include "hooks.h"

void	keyhandle(mlx_key_data_t keydata, void *param)
{
	t_game_manager	*manager;

	manager = (t_game_manager *)param;
	if (keydata.key == MLX_KEY_ESCAPE)
		game_manager_destroy(manager);
}

void handle_mouse(t_game *game)
{
	t_vec2_int	mouse_pos;
	mlx_t		*mlx;

	mlx = game->screen->mlx;
	mlx_set_cursor_mode(mlx, MLX_MOUSE_HIDDEN);
	mlx_get_mouse_pos(mlx, &mouse_pos.x, &mouse_pos.y);
	rotate(game->player, 0.1 * (mouse_pos.x - mlx->width / 2), mlx->delta_time);
	mlx_set_mouse_pos(mlx, mlx->width / 2, mlx->height / 2);
}