42_cub3d/algo.h
2024-10-15 16:03:18 +02:00

80 lines
2.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* algo.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <mcolonna@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/30 15:45:59 by grobledo #+# #+# */
/* Updated: 2024/10/15 15:48:45 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ALGO_H
# define ALGO_H
# include <unistd.h>
# include <math.h>
# include <stdbool.h>
# include "Minilibx/mlx.h"
# include "Minilibx/mlx_int.h"
# include "Libft/libft.h"
# define MAP_WIDTH 24 // cases (TODO test)
# define MAP_HEIGHT 24 // cases (TODO test)
# define TEX_WIDTH 64
# define TEX_HEIGHT 64
# define MOVE_SPEED 0.1 // cases
# define PI 3.1415926535
# define ROT_SPEED_DIVIDE_PI 16 // pi/n rad
# define COLOR_WALL 0xFF0000 // 0xRRGGBB
# define COLOR_CEILING 0x29f8ff // 0xRRGGBB
# define COLOR_FLOOR 0xFF985C // 0xRRGGBB
# define SCREEN_WIDTH 640 // px
# define SCREEN_HEIGHT 480 // px
# define FOV 0.66 // ? TODO unit
typedef struct s_point_double
{
double x;
double y;
} t_point_double;
typedef struct s_point_int
{
int x;
int y;
} t_point_int;
typedef struct s_ray
{
// pos player on map (cases)
t_point_double pos;
// player rotation (rad)
double rot;
} t_ray;
extern void *g_mlx;
extern void *g_win;
extern t_ray g_ray;
extern int g_world_map[MAP_WIDTH][MAP_HEIGHT];
typedef struct s_tex
{
void *tex_north;
void *tex_south;
void *tex_east;
void *tex_west;
void *current_tex;
} t_tex;
void vector_from_rotation(t_point_double *vec, double angle, double norm);
int keypress(int keycode);
int render(u_int32_t *img_data);
void draw_screen(void);
#endif