diff options
Diffstat (limited to 'map_spawn.c')
-rw-r--r-- | map_spawn.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/map_spawn.c b/map_spawn.c new file mode 100644 index 0000000..521eeef --- /dev/null +++ b/map_spawn.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* map_spawn.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/10/10 21:42:00 by kdx #+# #+# */ +/* Updated: 2022/10/11 00:27:03 by kdx ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "map.h" +#include "game.h" + +void map_spawn(t_game *game, t_map *map) +{ + size_t x; + size_t y; + int tile; + + y = -1; + while (++y < map->height) + { + x = -1; + while (++x < map->width) + { + tile = map_get(map, x * TSIZE, y * TSIZE); + if (tile == TILE_PLAYER) + { + game->player.pos[0] = x * TSIZE; + game->player.pos[1] = y * TSIZE; + map_set(map, x * TSIZE, y * TSIZE, '0'); + } + } + } +} |