-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.c
35 lines (27 loc) · 1.1 KB
/
main.c
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
#include "mlx_sample.h"
int main()
{
// ----------
// Struct with all the info that I need to run the program (mlx_sample.h)
t_program program;
// mlx function that initialize the mlx and returns a pointer to it.
program.mlx = mlx_init();
// Open a window (window.c whitin this project)
program.window = ft_new_window(program.mlx, 1980, 1080, "Hello world!");
// ----------
// Create a new image/sprite (image.c)
program.sprite = ft_new_sprite(program.mlx, "block.xpm");
program.sprite_position.x = 0;
program.sprite_position.y = 0;
// mlx function that draws an image into a window at the given position
mlx_put_image_to_window(program.mlx, program.window.reference,
program.sprite.reference, program.sprite_position.x, program.sprite_position.y);
// ----------
// hook the input() (hooks.c) function to the the key pressed event
mlx_key_hook(program.window.reference, *ft_input, &program);
// hook a function to the loop (it would be called each frame)
mlx_loop_hook(program.mlx, *ft_update, &program);
// ----------
// mlx constant loop that keeps the detects the events
mlx_loop(program.mlx);
}