cub3d/cub3d.h

183 lines
5.2 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-10 11:32:15 +01:00
/* Updated: 2023/11/10 10:40: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-10 11:32:15 +01:00
typedef struct s_sprite
2023-11-03 22:51:26 +01:00
{
2023-11-04 03:34:03 +01:00
double distance;
2023-11-04 00:27:12 +01:00
double x;
double y;
2023-11-10 11:32:15 +01:00
double anitime;
2023-11-03 22:51:26 +01:00
int type;
2023-11-05 11:46:44 +01:00
int number;
2023-11-10 11:32:15 +01:00
int status;
2023-11-03 22:51:26 +01:00
} t_sprite;
2023-11-10 11:32:15 +01:00
typedef struct s_draw
2023-11-05 11:46:44 +01:00
{
2023-11-10 11:32:15 +01:00
double tfx;
double tfy;
int sprs;
int vmov;
int sprh;
int sprw;
2023-11-05 11:46:44 +01:00
int drawstarty;
int drawstartx;
int drawendy;
int drawendx;
2023-11-10 11:32:15 +01:00
int x;
int y;
2023-11-05 11:46:44 +01:00
} t_draw;
2023-11-10 11:32:15 +01:00
typedef struct s_varlist
2023-10-25 14:07:29 +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;
2023-11-06 00:57:40 +01:00
mlx_image_t *cstat;
2023-11-04 04:40:26 +01:00
mlx_image_t *kstat;
2023-11-06 01:19:16 +01:00
mlx_image_t *astat;
mlx_image_t *hstat;
2023-11-10 11:32:15 +01:00
mlx_image_t **mstat;
2023-11-06 00:08:25 +01:00
mlx_image_t *wimg;
2023-11-10 11:32:15 +01:00
mlx_image_t *mimg;
mlx_image_t *oimg;
mlx_image_t *fimg;
mlx_texture_t *temptxt;
mlx_texture_t **walltxt;
mlx_texture_t **elevtxt;
mlx_texture_t **decotxt;
mlx_texture_t **picktxt;
mlx_texture_t **gfiretxt;
mlx_texture_t **gdeadtxt;
mlx_texture_t **gun0txt;
mlx_texture_t **gun1txt;
mlx_texture_t **gun2txt;
mlx_texture_t **gun3txt;
2023-11-03 22:51:26 +01:00
t_sprite *sprite;
int spritecount;
int w;
int h;
char **map;
2023-11-10 11:32:15 +01:00
int mapsizey;
int mapsizex;
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-10 11:32:15 +01:00
int mapx;
int mapy;
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-10 11:32:15 +01:00
double wdist;
int lineh;
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;
2023-11-10 11:32:15 +01:00
double tottime;
2023-11-06 00:57:40 +01:00
double firetime;
2023-11-04 04:40:26 +01:00
int enemies;
int kills;
int mgun;
int ggun;
2023-11-05 11:46:44 +01:00
int ammo;
2023-11-05 21:52:19 +01:00
int weapon;
2023-11-06 00:08:25 +01:00
int reload;
2023-11-10 11:32:15 +01:00
double reloadtime;
2023-11-06 01:19:16 +01:00
int hp;
2023-11-10 11:32:15 +01:00
int minimap;
int stats;
int menu;
char *cubfile;
int flash;
int flashcolor;
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);
2023-11-10 11:32:15 +01:00
void ft_resetvars(t_varlist *vl);
void ft_restartgame(t_varlist *vl);
void ft_raycast(t_varlist *vl, int x);
int ft_prepcast(t_varlist *vl, int x);
int ft_getstepx(t_varlist *vl, int mapx);
int ft_getstepy(t_varlist *vl, int mapy);
2023-11-05 08:00:55 +01:00
// PARSE
2023-10-26 17:40:01 +02:00
t_varlist ft_parseconfigfile(t_varlist vl, char *filename);
2023-11-10 11:32:15 +01:00
void ft_checkline(t_varlist *vl, char *line);
2023-10-29 14:27:34 +01:00
char **ft_getmap(t_varlist *vl, int fd);
2023-11-10 11:32:15 +01:00
char ft_checkmapelement(t_varlist *vl, char element, int x, int y);
char ft_initplayer(t_varlist *vl, char dir, int x, int y);
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-10 11:32:15 +01:00
int ft_floodfill(t_varlist vl);
int ft_flood(t_varlist vl, char **fillmap, int x, int y);
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);
2023-11-10 11:32:15 +01:00
void ft_processmove(t_varlist *vl, double mvs, double mvy, double mvx);
2023-11-05 06:38:58 +01:00
void ft_processacro(t_varlist *vl, double movespeed);
void ft_processguns(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-11-05 08:00:55 +01:00
// DRAW
2023-11-05 06:48:52 +01:00
void ft_drawmap(t_varlist *vl);
2023-11-06 00:08:25 +01:00
void ft_drawweapon(t_varlist *vl);
2023-11-10 11:32:15 +01:00
void ft_drawsprite(t_varlist *vl, t_draw *draw, int x, int i);
void ft_drawsprites(t_varlist *vl);
2023-11-05 07:27:38 +01:00
int ft_gettextx(t_varlist *vl);
2023-11-06 00:08:25 +01:00
uint32_t ft_gettextcolor(mlx_texture_t *texture, int texty, int textx);
2023-11-10 11:32:15 +01:00
void ft_flashscreen(t_varlist *vl, int x, int y, uint32_t color);
void ft_drawminimap(t_varlist *vl);
void ft_finish(t_varlist *vl);
void ft_youdied(t_varlist *vl);
// ACTION
2023-11-05 11:46:44 +01:00
void ft_checkpickup(t_varlist *vl);
2023-11-10 11:32:15 +01:00
void ft_firebullet(t_varlist *vl);
void ft_enemyaction(t_varlist *vl);
void ft_fireweapon(t_varlist *vl);
void ft_interact(t_varlist *vl);
void ft_checkhealth(t_varlist *vl);
2023-10-25 14:07:29 +02:00
#endif