diff options
Diffstat (limited to 'src/init.c')
| -rw-r--r-- | src/init.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -6,7 +6,7 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/09 14:50:09 by dkaiser #+# #+# */ -/* Updated: 2024/05/15 17:19:06 by dkaiser ### ########.fr */ +/* Updated: 2024/05/20 18:31:33 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,7 @@ int init(t_game *game) game->mlx = mlx_init(1920, 1080, "so_long", false); // TODO: make size and title dynamic game->input_direction = ZERO; + game->map.tile_size = (t_ivector){48, 48}; init_hooks(game); init_player(game); return (0); @@ -39,12 +40,10 @@ static void init_player(t_game *game) player = &game->player; texture = mlx_load_png("textures/player.png"); - player->position.x = game->map.player_start_tile.x * game->map.grid_size.x; - player->position.y = game->map.player_start_tile.y * game->map.grid_size.y; - player->velocity.x = 0; - player->velocity.y = 0; - player->size.x = 44; - player->size.y = 44; + player->position = grid_to_screen_pos(game->map.player_start_tile, + game->map.tile_size); + player->velocity = (t_vector){0, 0}; + player->size = (t_ivector){44, 44}; player->img = mlx_texture_to_image(game->mlx, texture); mlx_resize_image(player->img, player->size.x, player->size.y); mlx_image_to_window(game->mlx, player->img, player->position.x, |
