mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
style: split structs.h header into multiple, remove from central dir
This commit is contained in:
parent
38a05423dd
commit
6322d05b22
19 changed files with 141 additions and 87 deletions
29
src/cub3d_data.h
Normal file
29
src/cub3d_data.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* cub3d_data.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/07/17 14:59:37 by kcolin #+# #+# */
|
||||||
|
/* Updated: 2025/07/17 15:54:29 by kcolin ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef CUB3D_DATA_H
|
||||||
|
# define CUB3D_DATA_H
|
||||||
|
|
||||||
|
# include "map/mapdata.h"
|
||||||
|
# include "draw/img_data.h"
|
||||||
|
# include "player/player.h"
|
||||||
|
|
||||||
|
typedef struct s_cub3d_data
|
||||||
|
{
|
||||||
|
void *mlx;
|
||||||
|
void *mlx_win;
|
||||||
|
t_img_data *img_data;
|
||||||
|
t_mapdata *map;
|
||||||
|
t_player player;
|
||||||
|
} t_cub3d_data;
|
||||||
|
|
||||||
|
#endif // CUB3D_DATA_H
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:20:00 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:20:00 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:30:59 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:55:44 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../includes/structs.h"
|
#include "../map/mapdata.h"
|
||||||
|
#include "../player/player.h"
|
||||||
#include "drawutils.h"
|
#include "drawutils.h"
|
||||||
|
|
||||||
void draw_2d_wall(unsigned int color, t_mlx_data *data,
|
void draw_2d_wall(unsigned int color, t_img_data *data,
|
||||||
int x, int y)
|
int x, int y)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -33,7 +34,7 @@ void draw_2d_wall(unsigned int color, t_mlx_data *data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_map(t_mapdata *map, t_player *player, t_mlx_data *data)
|
void draw_map(t_mapdata *map, t_player *player, t_img_data *data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,17 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:20:13 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:20:13 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:35:31 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:52:07 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef DRAW_MAP_H
|
#ifndef DRAW_MAP_H
|
||||||
# define DRAW_MAP_H
|
# define DRAW_MAP_H
|
||||||
|
|
||||||
# include "../../includes/structs.h"
|
# include "../map/mapdata.h"
|
||||||
|
# include "../draw/img_data.h"
|
||||||
|
# include "../player/player.h"
|
||||||
|
|
||||||
void draw_map(t_mapdata *map, t_player *player, t_mlx_data *data);
|
void draw_map(t_mapdata *map, t_player *player, t_img_data *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:28:56 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:28:56 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:29:08 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:48:56 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../includes/structs.h"
|
#include "img_data.h"
|
||||||
|
|
||||||
void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color)
|
void my_mlx_pixel_put(t_img_data *data, int x, int y, int color)
|
||||||
{
|
{
|
||||||
char *dst;
|
char *dst;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,15 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:30:04 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:30:04 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:30:38 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:57:47 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef DRAWUTILS_H
|
#ifndef DRAWUTILS_H
|
||||||
# define DRAWUTILS_H
|
# define DRAWUTILS_H
|
||||||
|
|
||||||
# include "../../includes/structs.h"
|
# include "img_data.h"
|
||||||
|
|
||||||
void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color);
|
void my_mlx_pixel_put(t_img_data *data, int x, int y, int color);
|
||||||
|
|
||||||
#endif // DRAWUTILS_H
|
#endif // DRAWUTILS_H
|
||||||
|
|
|
||||||
25
src/draw/img_data.h
Normal file
25
src/draw/img_data.h
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* img_data.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/07/17 15:47:13 by kcolin #+# #+# */
|
||||||
|
/* Updated: 2025/07/17 15:47:39 by kcolin ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef IMG_DATA_H
|
||||||
|
# define IMG_DATA_H
|
||||||
|
|
||||||
|
typedef struct s_img_data
|
||||||
|
{
|
||||||
|
void *img;
|
||||||
|
char *addr;
|
||||||
|
int bits_per_pixel;
|
||||||
|
int line_length;
|
||||||
|
int endian;
|
||||||
|
} t_img_data;
|
||||||
|
|
||||||
|
#endif // IMG_DATA_H
|
||||||
21
src/main.c
21
src/main.c
|
|
@ -6,12 +6,11 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:55:29 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:52:57 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../libft/includes/libft.h"
|
#include "../libft/includes/libft.h"
|
||||||
#include "../includes/structs.h"
|
|
||||||
#include "../mlx/mlx.h"
|
#include "../mlx/mlx.h"
|
||||||
#include "consts.h"
|
#include "consts.h"
|
||||||
#include "map/map_checker.h"
|
#include "map/map_checker.h"
|
||||||
|
|
@ -34,11 +33,11 @@ int game_loop(t_cub3d_data *data)
|
||||||
{
|
{
|
||||||
data->player.x += data->player.movement.x;
|
data->player.x += data->player.movement.x;
|
||||||
data->player.y += data->player.movement.y;
|
data->player.y += data->player.movement.y;
|
||||||
mlx_destroy_image(data->mlx, data->mlx_data->img);
|
mlx_destroy_image(data->mlx, data->img_data->img);
|
||||||
data->mlx_data->img = mlx_new_image(data->mlx, 800, 600);
|
data->img_data->img = mlx_new_image(data->mlx, 800, 600);
|
||||||
draw_map(data->map, &data->player, data->mlx_data);
|
draw_map(data->map, &data->player, data->img_data);
|
||||||
mlx_put_image_to_window(data->mlx, data->mlx_win,
|
mlx_put_image_to_window(data->mlx, data->mlx_win,
|
||||||
data->mlx_data->img, 0, 0);
|
data->img_data->img, 0, 0);
|
||||||
mlx_string_put(data->mlx, data->mlx_win, 10, 10, 0x00FFFFFF, COMPILED_TEXT);
|
mlx_string_put(data->mlx, data->mlx_win, 10, 10, 0x00FFFFFF, COMPILED_TEXT);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
@ -55,11 +54,11 @@ int main(int argc, char **argv)
|
||||||
data.map->error), 1);
|
data.map->error), 1);
|
||||||
data.mlx = mlx_init();
|
data.mlx = mlx_init();
|
||||||
data.mlx_win = mlx_new_window(data.mlx, 800, 600, "Cub3d");
|
data.mlx_win = mlx_new_window(data.mlx, 800, 600, "Cub3d");
|
||||||
data.mlx_data = ft_calloc(sizeof(t_mlx_data), 1);
|
data.img_data = ft_calloc(sizeof(t_img_data), 1);
|
||||||
data.mlx_data->img = mlx_new_image(data.mlx, 800, 600);
|
data.img_data->img = mlx_new_image(data.mlx, 800, 600);
|
||||||
data.mlx_data->addr = mlx_get_data_addr(data.mlx_data->img,
|
data.img_data->addr = mlx_get_data_addr(data.img_data->img,
|
||||||
&data.mlx_data->bits_per_pixel, &data.mlx_data->line_length,
|
&data.img_data->bits_per_pixel, &data.img_data->line_length,
|
||||||
&data.mlx_data->endian);
|
&data.img_data->endian);
|
||||||
init_player(data.map, &(data.player));
|
init_player(data.map, &(data.player));
|
||||||
mlx_hook(data.mlx_win, KeyPress, KeyPressMask, keypress_handler, &data);
|
mlx_hook(data.mlx_win, KeyPress, KeyPressMask, keypress_handler, &data);
|
||||||
mlx_hook(data.mlx_win, KeyRelease, KeyReleaseMask,
|
mlx_hook(data.mlx_win, KeyRelease, KeyReleaseMask,
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:15:26 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:15:26 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:45:47 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:53:29 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../libft/includes/libft.h"
|
#include "../../libft/includes/libft.h"
|
||||||
#include "../../includes/structs.h"
|
|
||||||
#include "forbidden_characters.h"
|
#include "forbidden_characters.h"
|
||||||
|
#include "mapdata.h"
|
||||||
|
|
||||||
bool check_filename(t_mapdata *map, char *file)
|
bool check_filename(t_mapdata *map, char *file)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:39:41 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:39:41 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:41:45 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:55:09 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef CHECKERS_H
|
#ifndef CHECKERS_H
|
||||||
# define CHECKERS_H
|
# define CHECKERS_H
|
||||||
|
|
||||||
# include "../../includes/structs.h"
|
# include <stdbool.h>
|
||||||
|
# include "mapdata.h"
|
||||||
|
|
||||||
bool check_filename(t_mapdata *map, char *file);
|
bool check_filename(t_mapdata *map, char *file);
|
||||||
void populate_maps(t_mapdata *map, int fd);
|
void populate_maps(t_mapdata *map, int fd);
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,11 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/06/06 17:54:42 by tchampio #+# #+# */
|
/* Created: 2025/06/06 17:54:42 by tchampio #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:47:16 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:53:51 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../libft/includes/libft.h"
|
#include "../../libft/includes/libft.h"
|
||||||
#include "../../includes/structs.h"
|
|
||||||
#include "../utils/colors.h"
|
#include "../utils/colors.h"
|
||||||
#include "checkers.h"
|
#include "checkers.h"
|
||||||
#include "setters.h"
|
#include "setters.h"
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:34:38 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:34:38 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:35:09 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:49:16 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef MAP_CHECKER_H
|
#ifndef MAP_CHECKER_H
|
||||||
# define MAP_CHECKER_H
|
# define MAP_CHECKER_H
|
||||||
|
|
||||||
# include "../../includes/structs.h"
|
# include "mapdata.h"
|
||||||
|
|
||||||
bool check_cubfile(char *file, t_mapdata *map);
|
bool check_cubfile(char *file, t_mapdata *map);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,20 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* structs.h :+: :+: :+: */
|
/* mapdata.h :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/15 10:32:57 by tchampio #+# #+# */
|
/* Created: 2025/07/17 14:58:19 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/15 10:32:58 by tchampio ### ########.fr */
|
/* Updated: 2025/07/17 15:57:59 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef STRUCTS_H
|
#ifndef MAPDATA_H
|
||||||
# define STRUCTS_H
|
# define MAPDATA_H
|
||||||
|
|
||||||
# include <stdbool.h>
|
# include <stdbool.h>
|
||||||
|
|
||||||
typedef struct s_mlx_data
|
|
||||||
{
|
|
||||||
void *img;
|
|
||||||
char *addr;
|
|
||||||
int bits_per_pixel;
|
|
||||||
int line_length;
|
|
||||||
int endian;
|
|
||||||
} t_mlx_data;
|
|
||||||
|
|
||||||
typedef enum e_direction
|
typedef enum e_direction
|
||||||
{
|
{
|
||||||
NORTH,
|
NORTH,
|
||||||
|
|
@ -32,12 +23,6 @@ typedef enum e_direction
|
||||||
WEST
|
WEST
|
||||||
} t_direction;
|
} t_direction;
|
||||||
|
|
||||||
typedef struct s_vec2
|
|
||||||
{
|
|
||||||
double x;
|
|
||||||
double y;
|
|
||||||
} t_vec2;
|
|
||||||
|
|
||||||
typedef struct s_mapdata
|
typedef struct s_mapdata
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
@ -58,22 +43,4 @@ typedef struct s_mapdata
|
||||||
char error[1024];
|
char error[1024];
|
||||||
} t_mapdata;
|
} t_mapdata;
|
||||||
|
|
||||||
typedef struct s_player
|
#endif // MAPDATA_H
|
||||||
{
|
|
||||||
double x;
|
|
||||||
double y;
|
|
||||||
double yaw;
|
|
||||||
int health;
|
|
||||||
t_vec2 movement;
|
|
||||||
} t_player;
|
|
||||||
|
|
||||||
typedef struct s_cub3d_data
|
|
||||||
{
|
|
||||||
void *mlx;
|
|
||||||
void *mlx_win;
|
|
||||||
t_mlx_data *mlx_data;
|
|
||||||
t_mapdata *map;
|
|
||||||
t_player player;
|
|
||||||
} t_cub3d_data;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -6,11 +6,10 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:44:02 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:44:02 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:52:01 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:53:38 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../includes/structs.h"
|
|
||||||
#include "../../libft/includes/libft.h"
|
#include "../../libft/includes/libft.h"
|
||||||
#include "setters.h"
|
#include "setters.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:40:32 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:40:32 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:42:15 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:54:11 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef SETTERS_H
|
#ifndef SETTERS_H
|
||||||
# define SETTERS_H
|
# define SETTERS_H
|
||||||
|
|
||||||
# include "../../includes/structs.h"
|
# include <stdbool.h>
|
||||||
|
# include "mapdata.h"
|
||||||
|
|
||||||
bool add_textures(int fd, t_mapdata *map);
|
bool add_textures(int fd, t_mapdata *map);
|
||||||
void add_map_line(const char *line, t_mapdata *map);
|
void add_map_line(const char *line, t_mapdata *map);
|
||||||
|
|
|
||||||
31
src/player/player.h
Normal file
31
src/player/player.h
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* player.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/07/17 15:51:29 by kcolin #+# #+# */
|
||||||
|
/* Updated: 2025/07/17 15:51:42 by kcolin ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef PLAYER_H
|
||||||
|
# define PLAYER_H
|
||||||
|
|
||||||
|
typedef struct s_vec2
|
||||||
|
{
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
} t_vec2;
|
||||||
|
|
||||||
|
typedef struct s_player
|
||||||
|
{
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
double yaw;
|
||||||
|
int health;
|
||||||
|
t_vec2 movement;
|
||||||
|
} t_player;
|
||||||
|
|
||||||
|
#endif // PLAYER_H
|
||||||
|
|
@ -6,13 +6,14 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 13:59:27 by kcolin #+# #+# */
|
/* Created: 2025/07/17 13:59:27 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:47:25 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:55:22 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../includes/structs.h"
|
|
||||||
#include "../../mlx/mlx.h"
|
#include "../../mlx/mlx.h"
|
||||||
#include "../../libft/includes/libft.h"
|
#include "../../libft/includes/libft.h"
|
||||||
|
#include "../map/mapdata.h"
|
||||||
|
#include "../cub3d_data.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void free_tab(char **tab)
|
void free_tab(char **tab)
|
||||||
|
|
@ -62,9 +63,9 @@ int destroy(t_cub3d_data *data)
|
||||||
free_map(data->map);
|
free_map(data->map);
|
||||||
if (data->mlx_win)
|
if (data->mlx_win)
|
||||||
mlx_destroy_window(data->mlx, data->mlx_win);
|
mlx_destroy_window(data->mlx, data->mlx_win);
|
||||||
if (data->mlx_data)
|
if (data->img_data)
|
||||||
mlx_destroy_image(data->mlx, data->mlx_data->img);
|
mlx_destroy_image(data->mlx, data->img_data->img);
|
||||||
free(data->mlx_data);
|
free(data->img_data);
|
||||||
if (data->mlx)
|
if (data->mlx)
|
||||||
mlx_destroy_display(data->mlx);
|
mlx_destroy_display(data->mlx);
|
||||||
free(data->mlx);
|
free(data->mlx);
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:27:11 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:27:11 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:47:27 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:54:20 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef FREES_H
|
#ifndef FREES_H
|
||||||
# define FREES_H
|
# define FREES_H
|
||||||
|
|
||||||
# include "../../includes/structs.h"
|
# include "../cub3d_data.h"
|
||||||
|
|
||||||
void gnl_exhaust(int fd);
|
void gnl_exhaust(int fd);
|
||||||
int destroy(t_cub3d_data *data);
|
int destroy(t_cub3d_data *data);
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,11 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:22:57 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:22:57 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:55:42 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:53:49 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../consts.h"
|
#include "../consts.h"
|
||||||
#include "../../includes/structs.h"
|
|
||||||
#include "frees.h"
|
#include "frees.h"
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/07/17 14:23:06 by kcolin #+# #+# */
|
/* Created: 2025/07/17 14:23:06 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/07/17 14:24:58 by kcolin ### ########.fr */
|
/* Updated: 2025/07/17 15:50:08 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef HOOKS_H
|
#ifndef HOOKS_H
|
||||||
# define HOOKS_H
|
# define HOOKS_H
|
||||||
|
|
||||||
# include "../../includes/structs.h"
|
# include "../cub3d_data.h"
|
||||||
|
|
||||||
int keypress_handler(int keycode, t_cub3d_data *data);
|
int keypress_handler(int keycode, t_cub3d_data *data);
|
||||||
int keyrelease_handler(int keycode, t_cub3d_data *data);
|
int keyrelease_handler(int keycode, t_cub3d_data *data);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue