cub3d/inc/types.h
2025-05-16 15:02:43 +02:00

138 lines
2.6 KiB
C

/* ************************************************************************** */
/* */
/* :::::::: */
/* types.h :+: :+: */
/* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/15 15:52:44 by qmennen #+# #+# */
/* Updated: 2025/05/16 14:59:09 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#ifndef TYPES_H
# define TYPES_H
# include "cub3d.h"
typedef enum TILE
{
TILE_VISITED = -2,
TILE_VOID = -1,
TILE_EMPTY = 0,
TILE_WALL = 1,
TILE_PLAYER = 2,
} t_tile;
typedef struct s_vec2
{
double x;
double y;
} t_vec2;
typedef struct s_vec2_int
{
int x;
int y;
} t_vec2_int;
typedef struct s_range
{
int start;
int end;
} t_range;
typedef struct s_vec2_line
{
t_vec2 support;
t_vec2 dir;
} t_vec2_line;
typedef struct s_player
{
t_vec2 pos;
t_vec2 dir;
t_vec2 camera;
double speed;
int is_moving;
} t_player;
typedef struct s_sprite
{
int n_frames;
double dist;
double cam_frac;
int alpha;
mlx_texture_t *texture;
t_vec2 pos;
} t_sprite;
typedef struct s_map
{
unsigned int width;
unsigned int height;
t_tile **grid;
char *north_texture;
char *south_texture;
char *west_texture;
char *east_texture;
mlx_texture_t *texture_floor;
mlx_texture_t *texture_ceiling;
mlx_texture_t *textures[4];
t_sprite *sprites;
unsigned int n_sprites;
unsigned int floor_color;
unsigned int ceiling_color;
} t_map;
typedef struct s_keyboard
{
int keys[NUM_KEYS];
int last_keys[NUM_KEYS];
} t_keyboard;
typedef struct s_screen
{
mlx_t *mlx;
mlx_image_t *img;
mlx_image_t *minimap;
mlx_image_t *background;
mlx_image_t *hud;
unsigned int width;
unsigned int height;
} t_screen;
typedef enum e_side
{
SIDE_NORTH,
SIDE_SOUTH,
SIDE_WEST,
SIDE_EAST,
} t_side;
typedef struct s_render
{
double perp_dist;
t_side side;
double wall_x;
} t_render;
typedef struct s_sprite_column
{
t_vec2_int start;
t_vec2_int end;
int x;
} t_sprite_column;
typedef struct s_game
{
t_map *map;
t_player *player;
t_screen *screen;
t_keyboard *keyboard;
int framecount;
int fps;
} t_game;
#endif