42_cube3D/game/game.h

94 lines
2.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* game.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/26 15:29:34 by erey-bet #+# #+# */
/* Updated: 2023/05/09 13:11:40 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef GAME_H
# define GAME_H
# include "../cube3D.h"
# include <math.h>
# include <stdlib.h>
# define WIDTH 1920
# define HEIGHT 1080
# define MOVESPEED 0.10
# define ROTATIONSPEED 60
typedef struct s_player
{
double pos_x;
double pos_y;
double dir_x;
double dir_y;
double pla_x;
double pla_y;
} t_ply;
typedef struct s_raycast
{
double dir_x;
double dir_y;
} t_ray;
typedef struct s_dda
{
int map_x;
int map_y;
double side_dist_x;
double side_dist_y;
double delta_dist_x;
double delta_dist_y;
double perp_wall_dist;
int step_x;
int step_y;
int hit;
int side;
int line_height;
int draw_start;
int draw_end;
} t_dda;
typedef struct s_texture_draw
{
mlx_texture_t *texture;
double wall_x;
int x;
int y;
double pos;
double step;
} t_texture_draw;
typedef struct s_game
{
mlx_t *mlx;
mlx_image_t *window;
mlx_texture_t *textures[4];
t_ply ply;
t_map map;
t_ray ray;
} t_game;
/* INIT */
int init(t_map map, t_game *game);
/* MANAGE */
void manage(mlx_key_data_t keydata, void *param);
/* KEYS */
int manage_keys(mlx_key_data_t keydata, t_game *game);
/* RAYCASTING */
int raycasting(t_game *game);
/* DDA ALGO */
void dda(t_game *game, int x);
#endif