cub3d/cub3d.h

118 lines
3.1 KiB
C
Raw Normal View History

2023-10-25 14:07:29 +02:00
/* ************************************************************************** */
/* */
2023-10-26 11:01:31 +02:00
/* :::::::: */
2023-10-26 10:45:19 +02:00
/* cub3d.h :+: :+: */
2023-10-26 11:01:31 +02:00
/* +:+ */
/* By: houtworm <codam@houtworm.net> +#+ */
/* +#+ */
/* Created: 2023/10/26 10:46:35 by houtworm #+# #+# */
2023-11-04 04:40:26 +01:00
/* Updated: 2023/11/04 04:36:12 by houtworm ######## odam.nl */
2023-10-25 14:07:29 +02:00
/* */
/* ************************************************************************** */
2023-10-26 10:45:19 +02:00
#ifndef CUB3D_H
# define CUB3D_H
2023-10-25 14:07:29 +02:00
# include <unistd.h>
# include <math.h>
2023-10-26 17:40:01 +02:00
# include <fcntl.h>
2023-10-25 14:07:29 +02:00
# include "libft/libft.h"
2023-10-26 17:40:01 +02:00
# include "getnextline/get_next_line.h"
2023-10-25 14:07:29 +02:00
# include "mlx/include/MLX42/MLX42.h"
2023-10-31 16:29:35 +01:00
# include <stdio.h>
2023-10-25 14:07:29 +02:00
2023-11-03 22:51:26 +01:00
typedef struct s_sprite
{
2023-11-04 03:34:03 +01:00
double distance;
2023-11-04 00:27:12 +01:00
double x;
double y;
2023-11-03 22:51:26 +01:00
int type;
} t_sprite;
2023-10-25 14:07:29 +02:00
typedef struct s_varlist
{
mlx_t *mlx;
mlx_image_t *img;
2023-10-29 17:22:15 +01:00
mlx_image_t *fps;
2023-11-04 04:40:26 +01:00
mlx_image_t *tstat;
mlx_image_t *kstat;
2023-10-31 16:29:35 +01:00
mlx_texture_t *curtext;
2023-11-01 16:13:18 +01:00
mlx_texture_t *northtext;
mlx_texture_t *easttext;
mlx_texture_t *southtext;
mlx_texture_t *westtext;
mlx_texture_t *barreltext;
2023-11-03 22:51:26 +01:00
mlx_texture_t *hlamptext;
mlx_texture_t *slamptext;
mlx_texture_t *treasuretext;
mlx_texture_t *endtext;
mlx_texture_t *nazitext;
2023-11-03 22:51:26 +01:00
t_sprite *sprite;
int spritecount;
2023-10-29 17:22:15 +01:00
int fpsrefresh;
int w;
int h;
char **map;
2023-10-27 15:18:02 +02:00
double frametime;
2023-10-26 23:48:16 +02:00
double posx;
double posy;
double dirx;
double diry;
double planex;
double planey;
double camerax;
double cameray;
2023-10-31 16:29:35 +01:00
int hoffset;
2023-10-26 23:48:16 +02:00
double raydirx;
double raydiry;
2023-10-27 15:18:02 +02:00
double movespeed;
double rotspeed;
2023-10-26 23:48:16 +02:00
int mapx;
int mapy;
double sidedistx;
double sidedisty;
double deltadistx;
double deltadisty;
double perpwalldist;
2023-10-31 16:29:35 +01:00
int lineheight;
2023-10-26 23:48:16 +02:00
int stepx;
int stepy;
int hit;
int side;
2023-10-29 15:59:24 +01:00
double run;
2023-10-29 12:11:25 +01:00
double oldmouseposx;
2023-11-02 04:30:19 +01:00
double oldmouseposy;
2023-10-27 20:07:11 +02:00
int32_t fcolor;
int32_t ccolor;
2023-10-29 14:27:34 +01:00
int resize;
2023-11-04 00:27:12 +01:00
int *zbuffer;
2023-11-04 04:40:26 +01:00
int treasure;
int tottreasure;
int enemies;
int kills;
int mgun;
int ggun;
2023-10-25 14:07:29 +02:00
} t_varlist;
2023-10-29 14:27:34 +01:00
void ft_frametime(t_varlist *vl);
// init.c
t_varlist initvarlist(void);
// parse.c
2023-10-26 17:40:01 +02:00
t_varlist ft_parseconfigfile(t_varlist vl, char *filename);
2023-10-27 15:18:02 +02:00
// map.c
2023-10-29 14:27:34 +01:00
char **ft_getmap(t_varlist *vl, int fd);
// keys.c
void ft_movementkeys(t_varlist *vl);
void keyhook(mlx_key_data_t kd, void *param);
void scrollhook(double xdelta, double ydelta, void *param);
void resizehook(int x, int y, void *param);
2023-10-29 12:11:25 +01:00
void cursorhook(double x, double y, void *param);
2023-10-27 15:18:02 +02:00
// raycast.c
void ft_raycast(t_varlist *vl);
// draw.c
2023-10-27 15:18:02 +02:00
void ft_drawline(int x, t_varlist *vl, int drawstart, int drawend);
2023-11-03 22:51:26 +01:00
void ft_drawsprites(t_varlist *vl);
2023-10-26 17:40:01 +02:00
// error.c
int ft_errorexit(char *reason, char *function, int code);
2023-10-25 14:07:29 +02:00
#endif