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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sily.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/07 04:32:07 by kdx #+# #+# */
/* Updated: 2022/10/14 03:26:49 by kdx ### ########.fr */
/* */
/* ************************************************************************** */
/* 102761446 */
#ifndef SILY_H
# define SILY_H
# include "minilibx/mlx.h"
# include "libft/libft.h"
# include <stdbool.h>
# define MIN_DT 33
typedef struct s_game t_game;
typedef struct s_sily t_sily;
struct s_sily
{
void *ctx;
void *window;
int width;
int height;
bool quit;
void (*update)(t_sily *);
void (*draw)(t_sily *);
t_u64 tick;
t_u64 next_time;
t_u64 prev_move_events;
t_u64 move_events;
int input[4];
int input_queue[4];
t_game *game;
};
t_err sily_init(t_sily *s, int width, int height, char *title);
void sily_deinit(t_sily *s);
void sily_loop(t_sily *s, void (*update)(t_sily *), void (*draw)(t_sily *));
t_u64 sily_get_time(void);
void sily_sleep(t_u64 millis);
enum {
K_LEFT = 0,
K_RIGHT = 1,
K_DOWN = 2,
K_UP = 3,
};
void sily_input_update(t_sily *sily);
int sily_input_press_ev(int key, t_sily *sily);
int sily_input_release_ev(int key, t_sily *sily);
void sily_input_draw(t_sily *sily);
void sily_clear(t_sily *sily);
int sily_expose_hook(t_sily *sily);
void sily_erase_text(t_sily *silly, char *str, int x, int y);
void sily_draw_text(t_sily *sily, char *str, int x, int y);
#endif
|