-
Notifications
You must be signed in to change notification settings - Fork 5
/
mlx_sample.h
67 lines (52 loc) · 1.17 KB
/
mlx_sample.h
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
#ifndef SAMPLE_LIB_H
# define SAMPLE_LIB_H
# include <mlx.h>
// ----------------------------------
// MACROS
# ifndef ANIMATION_FRAMES
# define ANIMATION_FRAMES 10
# endif
// ----------------------------------
// STRUCTS
/* vector with an x and y */
typedef struct s_vector
{
int x;
int y;
} t_vector;
/* A pointer to the window and its size */
typedef struct s_window {
void *reference;
t_vector size;
} t_window;
/* The 4 values that define a color */
typedef struct s_color {
int r;
int g;
int b;
int a;
} t_color;
/* all info needed for an image */
typedef struct s_image {
void *reference;
t_vector size;
char *pixels;
int bits_per_pixel;
int line_size;
int endian;
} t_image;
typedef struct s_program {
void *mlx;
t_window window;
t_image sprite;
t_vector sprite_position;
} t_program;
// ---------------------------------
// FUNCTIONS
t_window ft_new_window(void *mlx, int widht, int height, char *name);
t_image ft_new_sprite(void *mlx, char *path);
t_color new_color(int r, int g, int b, int a);
void turn_img_to_color(t_image *image, t_color color);
int ft_input(int key, void *program);
int ft_update (void *param);
#endif