-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfdf.h
More file actions
121 lines (100 loc) · 2.98 KB
/
fdf.h
File metadata and controls
121 lines (100 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fdf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ishakuro <ishakuro@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/11 10:30:08 by ishakuro #+# #+# */
/* Updated: 2022/04/05 11:17:32 by ishakuro ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FDF_H
# define FDF_H
# include "minilibx/mlx.h"
# include "libft.h"
# include <math.h>
# include <errno.h>
# include <fcntl.h>
# include <stdlib.h>
# include <stdio.h> //temp
# define WIN_WIDTH 1280
# define WIN_HEIGHT 820
# define MLX_ERROR "MLX error."
# define IMG_ERROR "Image initialization error."
# define USAGE_ERROR "Usage: ./fdf <map_file>"
# define OPEN_MAP_ERROR "Failed to open a map."
# define INIT_MAP_ERROR "Failed to initialize a map."
# define READ_MAP_ERROR "Failed to read a map."
# define MALLOC_ERROR "Failed to allocate memory."
typedef struct s_map
{
int width;
int height;
int **lines;
int lines_capacity;
int zoom;
int color;
} t_map;
typedef struct s_mouse
{
int x;
int y;
int prev_x;
int prev_y;
} t_mouse;
typedef struct s_z
{
int z1;
int z2;
} t_z;
typedef struct s_mlx
{
void *mlx;
void *window;
void *img;
void *addr;
int bits_per_pixel;
int line_length;
int endian;
int offset_x;
int offset_y;
int raise_z;
float angle;
int projection;
t_map *map;
t_mouse *mouse;
int onclick;
} t_mlx;
typedef struct s_p
{
int x;
int y;
} t_p;
t_map *init_map(void);
t_mlx *init_mlx(t_map *map);
int read_map(const int fd, t_map *map);
int fill_struct(char **splitted_line, int width, t_map *map);
void my_mlx_pixel_put(t_mlx *mlx, int x, int y, int color);
int deal_key(int keycode, void *param);
int escape(void *param);
void keyboard_key(int keycode, t_mlx *mlx);
void projection(int keycode, t_mlx *mlx);
void setup_controls(t_mlx *mlx);
int ft_abs(int a);
int ft_direction(int a, int b);
int err_calculation(t_p *delta);
void bresenham(t_p p1, t_p p2, t_mlx *mlx);
void init_coordinates(t_p *p1, t_p *p2, t_z *z, t_mlx *mlx);
void zoom(t_p *p1, t_p *p2, t_mlx *mlx);
t_p point(int x, int y);
void draw(t_mlx *mlx);
int color(int z, int z2, t_map *map);
void init_img(t_mlx *mlx);
void destroy_img(t_mlx *mlx);
int mouse(int button, int x, int y, void *param);
int mouse_move(int x, int y, void *param);
int mouse_release(int button, int x, int y, void *param);
void exit_program(char *str);
void print_map(t_map *map);
#endif