Files
42_INT_10_cube3d/headers/cube3d_struct.h

137 lines
1.8 KiB
C

#ifndef CUBE3D_STRUCT_H
# define CUBE3D_STRUCT_H
/*
* 3 structs with coordinates for
* - simple precision point
* - double precision point
* - vector (two points)
*/
typedef struct s_d_coord
{
double x;
double y;
} t_d_coord;
typedef struct s_coord
{
int x;
int y;
} t_coord;
typedef struct s_vec
{
t_coord start;
t_coord end;
} t_vec;
/*
* struct with all elements for raycasting
*/
typedef struct s_rcast
{
t_vec screen_size;
t_vec ray;
t_vec wall;
int hor;
int screen_width;
int screen_height;
int screen_dist;
int cell;
int cell_x;
int cell_y;
int slope_x;
int slope_y;
int ray_sign_x;
int ray_sign_y;
int first_next_x;
int first_next_y;
int next_x;
int next_y;
int next_cell_x;
int next_cell_y;
int ray_step_x;
int ray_step_y;
int is_x;
int ray_nb;
int ray_len;
double ratio;
} t_rcast;
/*
* structs for windows, and images associated
*/
typedef struct s_win
{
void *ptr;
int size_x;
int size_y;
} t_win;
typedef struct s_img
{
void *ptr;
char *data;
int bpp;
int szl;
int ndn;
int height;
} t_img;
/*
* structs for the map
*/
typedef struct s_map
{
char **content;
int size_x;
int size_y;
int cell;
} t_map;
/*
* structs for the player and its moves
*/
typedef struct s_plr
{
// player
t_d_coord exact;
t_coord pos;
// rot
int rot;
double cosi;
double cosj;
double sini;
double sinj;
} t_plr;
/*
* struct with all elements for the project
*/
typedef struct s_game
{
void *mlx_ptr;
// game window
t_win win;
t_img img;
// player
t_plr plr;
// rays
t_rcast rcast;
// map
t_map map;
// map window
t_win map_win;
t_img map_img;
// key hook
int k_hook[MAX_NB_KEY];
} t_game;
#endif