better struct and files organization, and still only half raycast on map but no view created

This commit is contained in:
hugogogo
2022-04-22 17:38:29 +02:00
parent 00c9dfd6b8
commit fac1f78230
17 changed files with 602 additions and 505 deletions

View File

@@ -1,52 +1,129 @@
#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
{
int start_x;
int start_y;
int end_x;
int end_y;
t_coord start;
t_coord end;
} t_vec;
typedef struct s_game
/*
* struct with all elements for raycasting
*/
typedef struct s_rcast
{
// window
void *mlx_ptr;
void *win_ptr;
int win_size_x;
int win_size_y;
// rays
t_vec screen_dist;
t_vec screen_size;
t_vec ray;
// tmp
int ray_highlight;
int ray_activ;
// map
int map_size_x;
int map_size_y;
char **map;
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 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;
/*
* structs for the map
*/
typedef struct s_map
{
char **content;
int size_x;
int size_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
double plr_exact_x;
double plr_exact_y;
int plr_x;
int plr_y;
t_plr plr;
// rays
t_rcast rcast;
// map
t_map map;
// key hook
int k_hook[MAX_NB_KEY];
// image
void *img_ptr;
char *img_data;
int bpp;
int sizel;
int endian;
} t_game;
#endif