Files
42_INT_10_cube3d/headers/cube3d_struct.h
2022-05-02 09:39:03 +02:00

152 lines
2.1 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 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;
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;
/*
* wall textures and floor/ceiling colors
*/
typedef struct s_txt
{
char *txt_north;
char *txt_south;
char *txt_east;
char *txt_west;
int rgb_floor;
int rgb_ceiling;
} t_txt;
/*
* structs for the map
*/
typedef struct s_map
{
char **content;
char *tmp_str;
int size_x;
int size_y;
int cell;
int plr_x;
int plr_y;
} t_map;
/*
* structs for the player and its moves
*/
typedef struct s_plr
{
// player
t_d_coord exact;
t_coord pos;
// rot
int rot;
int deg;
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;
// textures and colors
t_txt txt;
// map
t_map map;
// key hook
int k_hook[MAX_NB_KEY];
} t_game;
#endif