aboutsummaryrefslogtreecommitdiffstats
path: root/inc/cub3d.h
blob: 7ea11d611d037a98eee27b7d505552ee535785c5 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* ************************************************************************** */
/*                                                          LE - /            */
/*                                                              /             */
/*   cub3d.h                                          .::    .:/ .      .::   */
/*                                                 +:+:+   +:    +:  +:+:+    */
/*   By: rbousset <marvin@le-101.fr>                +:+   +:    +:    +:+     */
/*                                                 #+#   #+    #+    #+#      */
/*   Created: 2020/02/02 17:19:43 by rbousset     #+#   ##    ##    #+#       */
/*   Updated: 2020/02/02 17:19:43 by rbousset    ###    #+. /#+    ###.fr     */
/*                                                         /                  */
/*                                                        /                   */
/* ************************************************************************** */

#	ifndef CUB3D_H
#	define CUB3D_H

#include <stddef.h>
#include <stdint.h>

#	ifndef FT_W_KEY
#	define FT_W_KEY 13
#	endif
#	ifndef FT_A_KEY
#	define FT_A_KEY 0
#	endif
#	ifndef FT_S_KEY
#	define FT_S_KEY 1
#	endif
#	ifndef FT_D_KEY
#	define FT_D_KEY 2
#	endif
#	ifndef FT_ESC_KEY
#	define FT_ESC_KEY 53
#	endif
#	ifndef FT_SCR_SIZE
#	define FT_SCR_SIZE 1980x1080
#	endif

typedef struct		s_win
{
	void			*wlx;
	void			*winptr;
	uint8_t			inited;
	uint16_t		x_max_size;
	uint16_t		y_max_size;
	uint16_t		x_size;
	uint16_t		y_size;
}					t_win;

typedef struct		s_img
{
	void			*img;
	char			*ptr;
	int				bpp;
	int				sizeline;
	int				endian;
}					t_img;

typedef struct		s_rgb
{
	int16_t			r;
	int16_t			g;
	int16_t			b;
}					t_rgb;

/*
** view_side:
** 1: North
** 2: East
** 3: South
** 4: West
*/

typedef struct		s_player
{
	float			pos_x;
	float			pos_y;
	float			view_side;
}					t_player;

typedef struct		s_cub
{
	char			*no_tex_path;
	char			*so_tex_path;
	char			*ea_tex_path;
	char			*we_tex_path;
	char			*sprite_path;
	char			*mapl;
	char			**map;
	size_t			map_w;
	size_t			map_h;
	size_t			line_chk;
	size_t			map_start;
	uint8_t			isspawn;
	uint8_t			scale;
	struct s_win	*wlist;
	struct s_player	*plist;
	struct s_img	img;
	struct s_rgb	f_rgb;
	struct s_rgb	c_rgb;
}					t_cub;

t_win				*ft_init_win(void);
t_cub				*ft_init_cub(void);
int					ft_key_event(int keycode, void *param);
int					ft_exit(uint8_t exit_code, t_cub *clist);
void				ft_drawsquare(int a, int b, int rgb, t_cub *clist);
void				ft_parse_map(const char *map_path, t_cub *clist);
int8_t				ft_select_get(char **words, t_cub *clist);
int8_t				ft_get_screen_size(t_win *wlist);
int8_t				ft_get_res(char **words, t_cub *clist);
int8_t				ft_get_tex_no(char **words, t_cub *clist);
int8_t				ft_get_tex_so(char **words, t_cub *clist);
int8_t				ft_get_tex_ea(char **words, t_cub *clist);
int8_t				ft_get_tex_we(char **words, t_cub *clist);
int8_t				ft_get_sprite(char **words, t_cub *clist);
int8_t				ft_get_f_color(char **words, t_cub *clist);
int8_t				ft_get_c_color(char **words, t_cub *clist);
int					ft_get_map_first_line(char *line, t_cub *clist);
int					ft_get_map_core(int fd, t_cub *clist);
void				ft_get_player_spawn(t_player *plist, t_cub *clist);
int					ft_check_missing(t_cub *clist);
int8_t				ft_check_map_line(char *line, uint8_t l, t_cub *clist);
size_t				ft_get_line_len(char *line);
int					ft_missing_error(const char *err, t_cub *clist);
uint8_t				ft_free_words(char **words);
int					ft_map_error(t_cub *clist);
int					ft_init_winlx(t_cub *clist);
void				ft_drawmap(t_cub *clist);
void				ft_print_list(t_cub *clist);
uint32_t			ft_rgb_to_hex(t_rgb rgb);

#	endif