summaryrefslogtreecommitdiff
path: root/src/init.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-05-10 12:26:25 +0200
committerGitHub2024-05-10 12:26:25 +0200
commit10b5c3a64680c4dc741cb41c5950abccbf310c7e (patch)
tree4a65d2387c6964ee9357d1ad17e7f9f5094ee99e /src/init.c
parente206d293aa947dc56fa8408c42dccaff9cb423c3 (diff)
parent461f71e2660e6286ffc757ca6b7077c70c80b6cf (diff)
downloadso_long-10b5c3a64680c4dc741cb41c5950abccbf310c7e.tar.gz
so_long-10b5c3a64680c4dc741cb41c5950abccbf310c7e.zip
Merge migrate-to-mlx42 into master
Migrate from the old mlx to MLX42
Diffstat (limited to 'src/init.c')
-rw-r--r--src/init.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/init.c b/src/init.c
index 0aa6664..bd6b48f 100644
--- a/src/init.c
+++ b/src/init.c
@@ -6,11 +6,10 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/09 14:50:09 by dkaiser #+# #+# */
-/* Updated: 2024/05/09 18:37:18 by dkaiser ### ########.fr */
+/* Updated: 2024/05/10 12:13:33 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
-#include "mlx.h"
#include "so_long.h"
static void init_hooks(t_game *game);
@@ -18,23 +17,27 @@ static void init_player(t_player *player, int x, int y);
int init(t_game *game)
{
- game->mlx = mlx_init();
- game->window = mlx_new_window(game->mlx, 1920, 1080, "so_long");
+ mlx_texture_t *texture;
+
+ 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);
+ 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_input, 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)