-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcub3d.h
111 lines (101 loc) · 2.86 KB
/
cub3d.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: achakour <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/14 10:19:24 by achakour #+# #+# */
/* Updated: 2025/01/28 11:02:44 by achakour ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CUB3D_H
#define CUB3D_H
# include "./minilibx-linux/mlx.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
# define UP 119
# define DOWN 115
# define RIGHT 100
# define LEFT 97
# define ESC 65307
# define Q 113
#define BUFFER_SIZE 13
#define PXL 40
#define WIN_WIDTH 1560
#define PI 3.14159
#define WIN_HIGHT 640
#define FOV (60 * (PI / 180.0))
typedef struct s_data {
void *img;
char *addr;
int bits_per_pixel;
int line_length;
int endian;
} t_data;
typedef struct s_ray {
int found_hrz;
int found_vrt;
int up_dowm;// 1 for up -1 for down
int right_left;//1 for right -1 for left
float distance;
float ray_angle;
float hrz_x;
float hrz_y;
float ver_x;
float ver_y;
float x_step;
float y_step;
} t_ray;
typedef struct s_player t_player;
typedef struct s_cub3d
{
t_data *img;
t_ray *rays;
t_player *player;
char **map;
int n_rays;
int win_width;
int win_height;
void *mlx;
void *mlx_win;
void *win;
int fd;
} t_cub3d;
typedef struct s_player
{
char **map;
float x_pos;
float y_pos;
int up_down;
int right_left;
float move_speed;
float rotat_angle;
float turn_speed;
t_cub3d *parent;
} t_player;
void ft_caster(t_cub3d *p);
void DDA(t_data *p, int X0, int Y0, int X1, int Y1);
int release_key(t_cub3d *p);
int game_loop(int keycode, t_cub3d *p);
float calc_direction(float angl, t_ray *ray);
void update_window(t_cub3d *p);
void ft_strlcpy(char *dst, char *src, size_t dstsize);
void my_mlx_pixel_put(t_data *data, int x, int y, int color);
char *ft_strdup(char *str);
void put_pixels(t_cub3d *p);
int check_wall(char **map ,float x, float y);
void put_images(t_cub3d *s);
int select_move(int keycode, t_cub3d *p);
void init_win(t_cub3d *p);
char **ft_split(char const *s, char c);
void *ft_exit(t_cub3d *p);
char **get_map(int fd);
int ft_strlen(const char *s);
void init_player(t_cub3d *strct, t_player *p);
char *ft_strjoin(char *s1, char *s2);
char *get_next_line(int fd);
#endif