aboutsummaryrefslogtreecommitdiff
path: root/cub3d.h
diff options
context:
space:
mode:
Diffstat (limited to 'cub3d.h')
-rw-r--r--cub3d.h116
1 files changed, 73 insertions, 43 deletions
diff --git a/cub3d.h b/cub3d.h
index aa30cf4..6f9ebef 100644
--- a/cub3d.h
+++ b/cub3d.h
@@ -1,19 +1,41 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* cub3d.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/11/15 06:40:37 by cacharle #+# #+# */
+/* Updated: 2019/11/15 09:28:43 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+#include <stdio.h>
+
#ifndef CUB3D_H
# define CUB3D_H
+# define MLXK_W 13
+# define MLXK_A 0
+# define MLXK_S 1
+# define MLXK_D 2
+# define MLXK_ESC 53
+
+# include <unistd.h>
+# include <fcntl.h>
# include <stdlib.h>
+# include "mlx.h"
# include "libft.h"
# define TRUE 1
# define FALSE 0
-typedef int t_bool;
+typedef int t_bool;
typedef struct
{
- int x;
- int y;
-} t_point;
+ int x;
+ int y;
+} t_vector;
typedef struct
{
@@ -37,55 +59,63 @@ typedef t_cell** t_map;
typedef struct
{
- int resolution_height;
- int resolution_width;
- char *north_texture_path;
- char *south_texture_path;
- char *west_texture_path;
- char *east_texture_path;
- char *sprite_texture_path;
- t_color floor_color;
- t_color ceilling_color;
- t_map map;
-} t_parsing;
-
-typedef struct
+ int resolution_height;
+ int resolution_width;
+ char *north_texture_path;
+ char *south_texture_path;
+ char *west_texture_path;
+ char *east_texture_path;
+ char *sprite_texture_path;
+ t_color floor_color;
+ t_color ceilling_color;
+ t_map map;
+ int map_width;
+ int map_height;
+} t_parsing;
+
+typedef struct s_state
{
- t_point origin;
- int angle;
-} t_ray;
+ t_bool running;
+ t_vector pos;
+ t_vector dir;
+ t_vector plane;
+} t_state;
-typedef struct
-{
- t_point a;
- t_point b;
-} t_wall;
+typedef t_bool (*t_option_parser_func)(t_parsing *parsing, char *line);
-typedef struct
+typedef struct s_option_parser
{
- t_point pos;
- int view_angle;
-} t_player;
+ char *id;
+ t_option_parser_func func;
+} t_option_parser;
-typedef struct
-{
- t_ray *rays;
- t_player player;
-} t_state;
+/*
+** parse.c
+*/
-typedef t_bool (*func)(t_parsing *parsing, char *line) t_line_parser_func;
+t_parsing *parse(char *filename);
+char **get_file_lines(char *filename);
+t_bool parse_line(t_parsing *parsing, char *line);
+t_parsing *parse_map(t_parsing *parsing, char **lines);
+t_cell *create_map_row(char *line);
-typedef struct
-{
- char *id;
- t_line_parser_func func;
-} t_line_parser;
+/*
+** parse_*.c
+*/
+
+t_bool parse_resolution(t_parsing *parsing, char *line);
+t_bool parse_north_texture(t_parsing *parsing, char *line);
+t_bool parse_south_texture(t_parsing *parsing, char *line);
+t_bool parse_west_texture(t_parsing *parsing, char *line);
+t_bool parse_east_texture(t_parsing *parsing, char *line);
+t_bool parse_sprite_texture(t_parsing *parsing, char *line);
+t_bool parse_floor_color(t_parsing *parsing, char *line);
+t_bool parse_ceilling_color(t_parsing *parsing, char *line);
/*
-** parse.c
+** event.c
*/
-t_parsing *parse(char *filename);
-t_bool parse_line(t_parsing *parsing, char *line);
+int handle_key(int key, void *param);
#endif