149 lines
2.0 KiB
C
149 lines
2.0 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_dist;
|
|
t_vec screen_size;
|
|
t_vec ray;
|
|
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 wall_height;
|
|
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 sizel;
|
|
int endian;
|
|
} 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[3];
|
|
int rgb_ceiling[3];
|
|
} t_txt;
|
|
|
|
/*
|
|
* structs for the map
|
|
*/
|
|
|
|
typedef struct s_map
|
|
{
|
|
char **content;
|
|
char *tmp_str;
|
|
int size_x;
|
|
int size_y;
|
|
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;
|
|
double cosi;
|
|
double cosj;
|
|
double sini;
|
|
double sinj;
|
|
} t_plr;
|
|
|
|
/*
|
|
* struct with all elements for the project
|
|
*/
|
|
|
|
typedef struct s_game
|
|
{
|
|
void *mlx_ptr;
|
|
// map window
|
|
t_win map_win;
|
|
t_img map_img;
|
|
// 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
|