2024-09-11 17:29:54 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* game.h :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2024/09/11 16:38:40 by adjoly #+# #+# */
|
2024-11-10 16:58:44 +01:00
|
|
|
/* Updated: 2024/11/10 16:41:35 by adjoly ### ########.fr */
|
2024-09-11 17:29:54 +02:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#ifndef GAME_H
|
|
|
|
# define GAME_H
|
|
|
|
|
2024-10-08 21:51:52 +02:00
|
|
|
# include <unistd.h>
|
2024-09-16 18:50:24 +02:00
|
|
|
# include <stdint.h>
|
2024-09-24 18:32:34 +02:00
|
|
|
# include <math.h>
|
|
|
|
# include <stdbool.h>
|
2024-10-08 21:51:52 +02:00
|
|
|
# include <stdlib.h>
|
|
|
|
# include <stddef.h>
|
|
|
|
# include <stdio.h>
|
2024-09-24 18:32:34 +02:00
|
|
|
|
2024-10-08 21:51:52 +02:00
|
|
|
# include "settings.h"
|
2024-10-28 14:41:48 +01:00
|
|
|
|
|
|
|
# include "vectwo.h"
|
|
|
|
|
|
|
|
# include "../parsing.h"
|
|
|
|
|
|
|
|
typedef struct s_map
|
|
|
|
{
|
|
|
|
char **arr;
|
2024-10-30 16:33:14 +01:00
|
|
|
int floor;
|
|
|
|
int celling;
|
2024-10-28 14:41:48 +01:00
|
|
|
char p_side;
|
|
|
|
t_coord p_spawnpoint;
|
|
|
|
t_coord size;
|
|
|
|
} t_map;
|
|
|
|
|
|
|
|
typedef struct s_player
|
|
|
|
{
|
|
|
|
t_vec2 coord;
|
2024-10-30 16:33:14 +01:00
|
|
|
float direction;
|
2024-11-07 12:23:38 +01:00
|
|
|
bool key[4];
|
2024-10-28 14:41:48 +01:00
|
|
|
} t_player;
|
2024-09-11 17:29:54 +02:00
|
|
|
|
2024-10-30 16:33:14 +01:00
|
|
|
typedef struct s_render
|
|
|
|
{
|
|
|
|
t_map *world;
|
|
|
|
void *mlx;
|
|
|
|
void *win;
|
|
|
|
void *img;
|
|
|
|
t_player *player;
|
|
|
|
void *texture[4];
|
|
|
|
} t_render;
|
|
|
|
|
2024-09-11 17:29:54 +02:00
|
|
|
/**
|
|
|
|
* @brief This function is used to handle keypress
|
|
|
|
*
|
|
|
|
* @param key The key code of the pressed key
|
|
|
|
* @param mlx The mlx pointer(internal to MacroLibX)
|
|
|
|
*
|
|
|
|
* @return Minilibx go brrrr(useless always 0)
|
|
|
|
*/
|
2024-11-10 16:58:44 +01:00
|
|
|
int key_down(int key, void *param);
|
|
|
|
int key_up(int key, void *param);
|
2024-09-16 18:50:24 +02:00
|
|
|
|
2024-09-24 18:32:34 +02:00
|
|
|
/**
|
|
|
|
* @brief This function is here to change the direction of the player
|
|
|
|
* by setting the t_player->direction and check overflow to be
|
|
|
|
* sure it stays between 0 and 2pi because it is expressed in
|
|
|
|
* radians
|
|
|
|
*
|
|
|
|
* @param speed The speed a which the player rotate
|
|
|
|
* @param clockwise The direction which the player rotate
|
|
|
|
* @param player A pointer to a t_player struct
|
|
|
|
*/
|
2024-10-30 16:33:14 +01:00
|
|
|
void change_direction(float speed, bool clockwise, t_player *player);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Render a cub3d frame by executing a dda on every ray and
|
|
|
|
* putting the pixel on the window
|
|
|
|
*
|
|
|
|
* @param render The render struct with everything i need
|
|
|
|
*/
|
|
|
|
void render_frame(t_render *render);
|
2024-09-24 18:32:34 +02:00
|
|
|
|
2024-09-11 17:29:54 +02:00
|
|
|
#endif
|