summaryrefslogtreecommitdiff
path: root/include/so_long.h
blob: e9097d1587acdcefdc01f67b9245bbeb991d94d0 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   so_long.h                                          :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2024/05/08 14:14:02 by dkaiser           #+#    #+#             */
/*   Updated: 2024/05/11 16:10:26 by dkaiser          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef SO_LONG_H
# define SO_LONG_H

# include "MLX42/MLX42.h"
# include "fcntl.h"
# include "libft.h"
# include "unistd.h"

# define PLAYER_MOVE_SPEED 250

enum			e_tile
{
	EMPTY = '0',
	WALL = '1',
	COLLECTIBLE = 'C',
	EXIT = 'E',
	PLAYER_START = 'P'
};

enum			e_direction
{
	ZERO = 0,
	UP = 1,
	DOWN = 2,
	LEFT = 4,
	RIGHT = 8
};

typedef struct s_vector
{
	double		x;
	double		y;
}				t_vector;

typedef struct s_ivector
{
	int			x;
	int			y;
}				t_ivector;

typedef struct s_player
{
	t_vector	position;
	t_vector	direction;
	t_vector	velocity;
	mlx_image_t	*img;
}				t_player;

typedef struct s_tilemap
{
	t_ivector	grid_size;
	t_ivector	tile_size;
	char		*tiles;
	t_ivector	player_start_tile;
	t_ivector	exit_tile;
}				t_tilemap;

typedef struct s_game
{
	mlx_t		*mlx;
	void		*window;
	t_player	player;
	int			input_direction;
	t_tilemap	map;
}				t_game;

int				load_map_from_file(t_tilemap *tilemap, char *filename);

int				init(t_game *game);
void			loop(void *params);
int				draw(t_game *game);
int				draw_map(t_game *game);
void			on_key_input(mlx_key_data_t event, void *params);

#endif // SO_LONG_H