diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/draw.c | 15 | ||||
| -rw-r--r-- | src/init.c | 7 | ||||
| -rw-r--r-- | src/map_utils.c | 16 |
3 files changed, 19 insertions, 19 deletions
@@ -6,7 +6,7 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/09 17:58:23 by dkaiser #+# #+# */ -/* Updated: 2024/05/11 16:00:17 by dkaiser ### ########.fr */ +/* Updated: 2024/05/15 15:09:38 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,12 +14,12 @@ #include "libft.h" #include "so_long.h" -int draw_map(t_game *game) +int draw_map(t_game *game) { - int x; - int y; - mlx_texture_t *wall_texture; - mlx_image_t *wall_image; + int x; + int y; + mlx_texture_t *wall_texture; + mlx_image_t *wall_image; wall_texture = mlx_load_png("textures/wall.png"); wall_image = mlx_texture_to_image(game->mlx, wall_texture); @@ -33,7 +33,8 @@ int draw_map(t_game *game) while (y < game->map.grid_size.y) { if (game->map.tiles[y * game->map.grid_size.x + x] == WALL) - mlx_image_to_window(game->mlx, wall_image, x * game->map.tile_size.x, y * game->map.tile_size.y); + mlx_image_to_window(game->mlx, wall_image, x + * game->map.tile_size.x, y * game->map.tile_size.y); y++; } x++; @@ -6,7 +6,7 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/09 14:50:09 by dkaiser #+# #+# */ -/* Updated: 2024/05/15 14:46:09 by dkaiser ### ########.fr */ +/* Updated: 2024/05/15 15:09:44 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,6 @@ static void init_actor(t_game *game); int init(t_game *game) { - game->mlx = mlx_init(1920, 1080, "so_long", false); // TODO: make size and title dynamic game->input_direction = ZERO; @@ -36,7 +35,7 @@ static void init_hooks(t_game *game) static void init_actor(t_game *game) { mlx_texture_t *texture; - t_actor *player; + t_actor *player; player = &game->player; texture = mlx_load_png("textures/player.png"); @@ -49,5 +48,5 @@ static void init_actor(t_game *game) 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, - player->position.y); + player->position.y); } diff --git a/src/map_utils.c b/src/map_utils.c index 82acaa9..6d8fbd9 100644 --- a/src/map_utils.c +++ b/src/map_utils.c @@ -6,7 +6,7 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/14 13:19:34 by dkaiser #+# #+# */ -/* Updated: 2024/05/14 14:44:39 by dkaiser ### ########.fr */ +/* Updated: 2024/05/15 15:04:31 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,16 +21,16 @@ t_vector grid_to_screen_pos(t_ivector grid_pos, t_ivector tile_size) return (screen_pos); } -t_ivector screen_to_grid_pos(t_vector screen_pos, t_ivector tile_size) +t_ivector screen_to_grid_pos(t_vector screen_pos, t_ivector tile_size) { - t_ivector grid_pos; + t_ivector grid_pos; - grid_pos.x = screen_pos.x / tile_size.x; - grid_pos.y = screen_pos.y / tile_size.y; - return (grid_pos); + grid_pos.x = screen_pos.x / tile_size.x; + grid_pos.y = screen_pos.y / tile_size.y; + return (grid_pos); } -enum e_tile get_tile(t_tilemap *map, int x, int y) +enum e_tile get_tile(t_tilemap *map, int x, int y) { - return map->tiles[y * map->grid_size.x + x]; + return (map->tiles[y * map->grid_size.x + x]); } |
