aboutsummaryrefslogtreecommitdiff
path: root/event.c
blob: 0d6c11302bdf5fc41df4de53b7b31efe119e3bcb (plain)
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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   event.c                                            :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2019/11/15 06:39:37 by cacharle          #+#    #+#             */
/*   Updated: 2019/11/16 12:44:15 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "cub3d.h"

int	handle_key(int key, void *param)
{
	t_state	*state;

	/* printf("%d\n", key); */
	state = (t_state*)param;
	if (key == MLXK_ESC)
		state->running = FALSE;
	if (key == MLXK_A)
		state->pos.x -= 0.5;
	if (key == MLXK_D)
		state->pos.x += 0.5;
	if (key == MLXK_W)
		state->pos.y -= 0.5;
	if (key == MLXK_S)
		state->pos.y += 0.5;
	return (0);
}