42_cub3d/algo.h
ReverseSky a824900a7c a
2024-10-15 13:58:25 +02:00

82 lines
No EOL
2.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* algo.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: greg <greg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/30 15:45:59 by grobledo #+# #+# */
/* Updated: 2024/10/14 17:54:17 by greg ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ALGO_H
#define ALGO_H
#include <unistd.h>
#include <math.h>
#include "Minilibx/mlx.h"
#include "Minilibx/mlx_int.h"
# include "Libft/libft.h"
#define mapWidth 24 // TEST
#define mapHeight 24 // TEST
#define texWidth 64
#define texHeight 64
typedef struct s_ray
{
// pos player on map
double posX;
double posY;
// orientation player on map
double dirX;
double dirY;
// orientation cam on map
double planeX;
double planeY;
// camera pos
double cameraX;
// direction rayon
double raydirX;
double raydirY;
// longueur du rayon entre pos actuelle et pos du prochain cote d'une box
double sidedistX;
double sidedistY;
// longueur du rayon entre pos d'un cote d'une box jusqu'a pos du prochain cote d'une box
double deltadistX;
double deltadistY;
// calcul lenght of ray (shortest perpendicular distance between wall and camera plane)
double perpwalldist;
// step direction (can be -1 or +1)
int stepX;
int stepY;
double movespeed;
double rotspeed;
double oldDirX;
double oldPlaneX;
void *mlx_ptr;
void *win_ptr;
void *img_ptr;
int *img_data;
int mapX;
int mapY;
double width;
double height;
} t_ray;
typedef struct s_tex
{
void *tex_north;
void *tex_south;
void *tex_east;
void *tex_west;
void *current_tex;
} t_tex;
extern int worldMap[mapWidth][mapHeight]; // TEST
int keypress(int keycode, t_ray *ray);
int render(t_ray *ray);
#endif