/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/08 14:14:02 by dkaiser #+# #+# */
-/* Updated: 2024/05/15 16:41:49 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 17:31:34 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
void player_process(t_game *game);
int draw(t_game *game);
int draw_walls(t_game *game);
+void draw_exit(t_game *game);
void on_key_input(mlx_key_data_t event, void *params);
t_vector grid_to_screen_pos(t_ivector grid_pos, t_ivector tile_size);
t_ivector screen_to_grid_pos(t_vector screen_pos, t_ivector tile_size);
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/09 17:58:23 by dkaiser #+# #+# */
-/* Updated: 2024/05/15 16:41:15 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 17:31:11 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "so_long.h"
+int draw(t_game *game)
+{
+ game->player.img->instances[0].x = game->player.position.x;
+ game->player.img->instances[0].y = game->player.position.y;
+ return (0);
+}
+
+void draw_exit(t_game *game)
+{
+ mlx_texture_t *exit_texture;
+ mlx_image_t *exit_image;
+ t_vector pos;
+
+ exit_texture = mlx_load_png("textures/exit.png");
+ exit_image = mlx_texture_to_image(game->mlx, exit_texture);
+ mlx_resize_image(exit_image, game->map.tile_size.x, game->map.tile_size.y);
+ pos = grid_to_screen_pos(game->map.exit_tile, game->map.tile_size);
+ mlx_image_to_window(game->mlx, exit_image, pos.x, pos.y);
+}
+
int draw_walls(t_game *game)
{
int x;
}
return (0);
}
-
-int draw(t_game *game)
-{
- game->player.img->instances[0].x = game->player.position.x;
- game->player.img->instances[0].y = game->player.position.y;
- return (0);
-}
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/09 14:50:09 by dkaiser #+# #+# */
-/* Updated: 2024/05/15 15:09:44 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 17:19:06 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
static void init_hooks(t_game *game);
-static void init_actor(t_game *game);
+static void init_player(t_game *game);
int init(t_game *game)
{
// TODO: make size and title dynamic
game->input_direction = ZERO;
init_hooks(game);
- init_actor(game);
+ init_player(game);
return (0);
}
mlx_key_hook(game->mlx, on_key_input, game);
}
-static void init_actor(t_game *game)
+static void init_player(t_game *game)
{
mlx_texture_t *texture;
t_actor *player;
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/08 14:14:13 by dkaiser #+# #+# */
-/* Updated: 2024/05/15 16:41:35 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 17:31:46 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
return (1);
init(&game);
draw_walls(&game);
+ draw_exit(&game);
mlx_loop(game.mlx);
}