#2D Procedural map generation

38 messages · Page 1 of 1 (latest)

junior hull
#

Using a spritesheet of tilemaps, how can I create a 2D procedural map generation in bevy?

arctic wave
#

So are you interested in the process of how to get where to place the tile or how to place the tiles themselves?

junior hull
#

both

#

currently I am using a random walk algorithm but thats just a placeholder

#

It also doesn't work as well as i'd like

arctic wave
#

Ok, firstly I won't go into too much on placing tiles. If you want to make your own implementation that is something you can do but something like bevy_ecs_tilemap will probably make it much easier. The documentation is pretty good.

junior hull
#

oh ok thank you

arctic wave
#

as for actually getting where to place the tiles the "best" way depends on your goal and type of game

#

Is it like a dungeon crawler? Top down open world game etc

junior hull
#

dungeon crawler

arctic wave
#

Yeah for dungeon crawlers there are a lot of different methods. I haven't done too much but I am aware of some popular techniques. You mentioned random walk algorithm. Another thing some people will do is make a set of pre made rooms then randomly choose a direction in each room and place another room in that direction. I've heard of people using cellular automata(basically a set of points in a grid that have a set of rules to determine where to place stuff). Is it something you want to implement yourself? If not I would maybe look at crates.io and see if there are any that do what you want. Otherwise a lot of it is just doing research on what method produces the result for your game. Probably the most simple but sometimes not great results depending on game is just choosing a random direction and placing premade rooms.

junior hull
#

pre made rooms?

#

hmmm

#

how would I do this with bevy?

#

also I would love to hear about cellular automata

arctic wave
#

Before I go further I took a look at crates.io to see if there are any libraries there appears one that seems to have a few premade mapgen options: https://crates.io/crates/mapgen if thats something ur interested in rather then fully implementing yourself

arctic wave
junior hull
#

hmmm ok

arctic wave
#

A lot of it just really depends on your goals, game, and time willing to dedicate to it

junior hull
#

what do you advise I should do?

#

use the mapgen crate or use cellular automata?

arctic wave
#

If you are doing a more room based dungeon crawler and don't want to write the mapgen completely by yourself personally I would at least try out the crate(Although i am not giving any guarantees about the crate I have never used it but found it in trying to research options for you) Or if you were interested in doing yourself look at implementations done by other people and start by trying a few learning projects to implement them

junior hull
#

hmmm

#

i think ill try the mapgen crate first, and if it doesn't suit my liking, ill try doing it myself

#

yeah I love BSP rooms from mapgen

#

its exactly what I wanted

arctic wave
junior hull
#

wait

arctic wave
junior hull
#

how do I use it for bevy if it seems to just

#

MapBuilder::new().build();

arctic wave
#

I didn't look at the crate but I would assume it has a function to get a tile from the map whether its a wall or not. If you look at the docs it should tell you

#

Then using the map data it generates you can render tiles based off of what it says

#

is walkable appears to have what you would need

junior hull
#

ahhh

#

thanks so much