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-05 11:53:15 +01:00
|
|
|
/* Updated: 2023/11/05 11:52: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;
|
2023-11-05 11:46:44 +01:00
|
|
|
int number;
|
2023-11-03 22:51:26 +01:00
|
|
|
} t_sprite;
|
|
|
|
|
2023-11-05 11:46:44 +01:00
|
|
|
typedef struct s_draw
|
|
|
|
{
|
|
|
|
double transformx;
|
|
|
|
double transformy;
|
|
|
|
int spritescreen;
|
|
|
|
int vmovescreen;
|
|
|
|
int spriteheight;
|
|
|
|
int spritewidth;
|
|
|
|
int drawstarty;
|
|
|
|
int drawstartx;
|
|
|
|
int drawendy;
|
|
|
|
int drawendx;
|
|
|
|
int texx;
|
|
|
|
int texy;
|
|
|
|
} t_draw;
|
|
|
|
|
2023-10-25 14:07:29 +02:00
|
|
|
typedef struct s_varlist
|
|
|
|
{
|
2023-10-26 16:57:23 +02:00
|
|
|
mlx_t *mlx;
|
|
|
|
mlx_image_t *img;
|
2023-11-05 04:53:41 +01:00
|
|
|
mlx_image_t *fstat;
|
2023-11-04 04:40:26 +01:00
|
|
|
mlx_image_t *tstat;
|
|
|
|
mlx_image_t *kstat;
|
2023-11-05 08:12:18 +01:00
|
|
|
mlx_texture_t *temptext;
|
2023-11-05 09:07:07 +01:00
|
|
|
mlx_texture_t **walltext;
|
|
|
|
mlx_texture_t **decotext;
|
|
|
|
mlx_texture_t **picktext;
|
|
|
|
mlx_texture_t **nazitext;
|
2023-11-03 22:51:26 +01:00
|
|
|
t_sprite *sprite;
|
|
|
|
int spritecount;
|
2023-10-26 16:57:23 +02:00
|
|
|
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;
|
2023-11-05 03:22:41 +01:00
|
|
|
int vaim;
|
|
|
|
int jump;
|
2023-11-05 04:53:41 +01:00
|
|
|
double run;
|
2023-10-26 23:48:16 +02:00
|
|
|
double raydirx;
|
|
|
|
double raydiry;
|
|
|
|
double sidedistx;
|
|
|
|
double sidedisty;
|
|
|
|
double deltadistx;
|
|
|
|
double deltadisty;
|
2023-11-05 06:38:58 +01:00
|
|
|
double walldist;
|
2023-10-31 16:29:35 +01:00
|
|
|
int lineheight;
|
2023-10-26 23:48:16 +02:00
|
|
|
int side;
|
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-11-05 04:16:49 +01:00
|
|
|
int *distance;
|
2023-11-04 04:40:26 +01:00
|
|
|
int treasure;
|
|
|
|
int tottreasure;
|
|
|
|
int enemies;
|
|
|
|
int kills;
|
|
|
|
int mgun;
|
|
|
|
int ggun;
|
2023-11-05 11:46:44 +01:00
|
|
|
int ammo;
|
2023-10-25 14:07:29 +02:00
|
|
|
} t_varlist;
|
|
|
|
|
2023-11-05 08:00:55 +01:00
|
|
|
// MAIN
|
|
|
|
t_varlist initgame(void);
|
|
|
|
int ft_errorexit(char *reason, char *function, int code);
|
|
|
|
void ft_printstats(t_varlist *vl);
|
|
|
|
void ft_cleanup(t_varlist *vl);
|
|
|
|
// PARSE
|
2023-10-26 17:40:01 +02:00
|
|
|
t_varlist ft_parseconfigfile(t_varlist vl, char *filename);
|
2023-10-29 14:27:34 +01:00
|
|
|
char **ft_getmap(t_varlist *vl, int fd);
|
2023-11-05 11:53:15 +01:00
|
|
|
char ft_addwalktroughdecor(t_varlist *vl, int x, int y, int number);
|
|
|
|
char ft_addsoliddecor(t_varlist *vl, int x, int y, int number);
|
|
|
|
char ft_addpickup(t_varlist *vl, int x, int y, int number);
|
|
|
|
char ft_addenemy(t_varlist *vl, int x, int y, int number);
|
2023-11-05 08:00:55 +01:00
|
|
|
// INPUT
|
2023-11-05 04:53:41 +01:00
|
|
|
void ft_processinput(t_varlist *vl);
|
2023-11-05 06:38:58 +01:00
|
|
|
void ft_processturn(t_varlist *vl, double rotspeed);
|
|
|
|
void ft_processmove(t_varlist *vl, double movespeed);
|
|
|
|
void ft_processacro(t_varlist *vl, double movespeed);
|
|
|
|
void ft_processguns(t_varlist *vl);
|
2023-10-26 16:57:23 +02:00
|
|
|
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-11-05 08:00:55 +01:00
|
|
|
// DRAW
|
2023-11-05 06:48:52 +01:00
|
|
|
void ft_raycast(t_varlist *vl, int x, int mapx, int mapy);
|
|
|
|
void ft_drawmap(t_varlist *vl);
|
2023-11-05 07:27:38 +01:00
|
|
|
int ft_gettextx(t_varlist *vl);
|
|
|
|
uint32_t ft_gettextcolor(t_varlist *vl, int texty, int textx);
|
2023-11-05 08:00:55 +01:00
|
|
|
// SPRITE
|
2023-11-05 11:46:44 +01:00
|
|
|
void ft_drawsprite(t_varlist *vl, t_draw *draw, int x);
|
|
|
|
t_draw *ft_initdrawsprite(t_varlist *vl, int i);
|
|
|
|
void ft_getdrawstartend(t_varlist *vl, t_draw *draw);
|
2023-11-05 08:00:55 +01:00
|
|
|
void ft_drawsprites(t_varlist *vl);
|
2023-11-05 11:46:44 +01:00
|
|
|
void ft_checkpickup(t_varlist *vl);
|
2023-10-25 14:07:29 +02:00
|
|
|
#endif
|