From 546c596505ded408bd0a73343618b100013d310f Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Fri, 10 May 2024 12:01:25 +0200 Subject: Replicate main functionality in MLX42 --- src/init.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/init.c') diff --git a/src/init.c b/src/init.c index 55e8fe0..5efec32 100644 --- a/src/init.c +++ b/src/init.c @@ -6,7 +6,7 @@ /* By: dkaiser mlx = mlx_init(); - game->window = mlx_new_window(game->mlx, 1920, 1080, "so_long"); + game->mlx = mlx_init(1920, 1080, "so_long", false); // TODO: make size and title dynamic game->input_direction = ZERO; init_hooks(game); init_player(&game->player, 960, 540); // TODO: make player spawn point dynamic - int w, h; - game->player.img = mlx_xpm_file_to_image(game->mlx, "textures/player.xpm", &w, &h); + mlx_texture_t *texture = mlx_load_png("textures/player.png"); + game->player.img = mlx_texture_to_image(game->mlx, texture); + mlx_image_to_window(game->mlx, game->player.img, game->player.position.x, game->player.position.y); return (0); } static void init_hooks(t_game *game) { mlx_loop_hook(game->mlx, loop, game); - mlx_hook(game->window, 2, 0, on_key_down, game); - mlx_hook(game->window, 3, 0, on_key_up, game); + mlx_key_hook(game->mlx, on_key_down, game); + /* mlx_hook(game->window, 2, 0, on_key_down, game); */ + /* mlx_hook(game->window, 3, 0, on_key_up, game); */ } static void init_player(t_player *player, int x, int y) -- cgit v1.2.3