-
Notifications
You must be signed in to change notification settings - Fork 0
/
wolf3d.h
137 lines (124 loc) · 3.61 KB
/
wolf3d.h
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
134
135
136
137
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* wolf3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lmarques <lmarques@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/25 01:19:41 by lmarques #+# #+# */
/* Updated: 2017/01/07 19:09:55 by lmarques ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef WOLF3D_H
# define WOLF3D_H
# include <math.h>
# include "./minilibx/mlx.h"
# include "./libft/libft.h"
# include "./libft/get_next_line.h"
# define W_WIDTH 800
# define W_HEIGHT 600
# define MIN_TEX 0
# define MAX_TEX 7
# define DEFAULT_TEX 0
# define FLOOR_TEX 1
# define CEILING_TEX 2
# define SPEED 20
typedef struct s_point
{
int x;
int y;
int id;
} t_point;
typedef struct s_dpoint
{
double x;
double y;
} t_dpoint;
typedef struct s_key
{
int keycode;
char state;
} t_key;
typedef struct s_key_list
{
t_key key;
struct s_key_list *next;
} t_key_list;
typedef struct s_tex
{
void *tex;
int *data;
int width;
int height;
} t_tex;
typedef struct s_meta
{
void *ptr;
void *win;
void *img;
int *data;
int bpp;
int size_line;
int endian;
t_tex texture[10];
} t_meta;
typedef struct s_camera
{
double pos_x;
t_dpoint screen;
} t_camera;
typedef struct s_player
{
t_key_list *key_list;
t_point *tab;
int tab_len;
t_meta mlx;
t_camera c;
t_dpoint pos;
t_point map_pos;
t_dpoint ray_pos;
t_dpoint ray_dir;
t_dpoint p_dir;
t_point p_dir_sign;
t_dpoint dist_side;
t_dpoint diff_side;
t_dpoint floor_wall;
double ray_len;
char found_wall;
char found_wall_side;
int color;
double wall;
} t_player;
int ft_get_len(t_point *tab);
void ft_init_struct(t_player *p, t_point *tab, int tab_len);
void ft_clear_image(t_player *p);
int ft_draw(t_player *p);
int ft_rotate(int x, int y, t_player *p);
void ft_move(t_player *p);
void ft_strafe(t_player *p);
t_point *ft_init_tab(char *name, int *err, int *len);
t_dpoint ft_search_id(t_point *tab, int len, int id);
int *ft_set_tmp(t_player *p);
void ft_apply_texture(t_player *p, int count, t_point pt,
int *tmp);
void ft_calc_wall_dist(t_player *p);
void ft_parse_keys_press(t_player *p, int keycode);
void ft_parse_keys_release(t_player *p, int keycode);
char ft_search_key(t_player *p, int keycode);
void ft_set_floor(t_player *p);
void ft_set_floor_to_buffer(t_player *p, int count,
t_point pt);
void ft_check_textures(t_player *p);
void ft_check_map(t_player *p, int len);
void ft_free_list(t_list **lst);
void ft_set_val(t_point *tab, t_point count, int id);
void ft_free_split(char **str);
int *ft_create_tab(char **tmp, int *err);
int ft_count_elem(char **tab);
void ft_split_and_push(char **ln, int *e, char ***tmp,
int **tmp3);
void ft_free(char ***tmp, char **ln, int **tmp2);
void ft_init_values(t_list **map, t_point *p, int **tmp2,
char **ln);
void ft_check_fd(int fd);
#endif