Log In  

What's a strategy or method I can explore for generating random platform levels within a given space?

Say I have a 32x32 square and want there to be a floor but random heights and pits. I want there to be exits on N sides so the player can go to the next square. But some squares will have some sides blocked as a dead end. Like a Metroid level, for example.

I can't use sprite maps, right? I would just be placing objects directly into a coordinate table and then drawing from that every cycle. But how do I populate that array smartly?

My big worry is just making sure there aren't any island squares where the player can't reach or exit.

The issue isn't just creating randomness...I know how to do that but how do you create something that smartly groups together blocks within constraints? Pure random placement doesn't do this, I know.

Just looking for thoughts on how to approach it and/or generate such an thing.

Any insight is appreciated.

P#23295 2016-06-20 13:51 ( Edited 2016-06-21 07:46)

I guess in my head I can create (or use) something that I feed settings and out comes a table. Like...

generateMap(height, width, blockSize, numOfExits, maxHeight, numOfPits)

Or something like that...

The more I talk and think, I'm probably over-thinking it...but hey...

P#23296 2016-06-20 13:54 ( Edited 2016-06-20 17:54)

Maybe thinking it's better to make pre-defined maps that can then be put in random order? But that doesn't sound as "infinite" as I'd like...

P#23298 2016-06-20 14:02 ( Edited 2016-06-20 18:02)

Do you want every exit to be reachable from every other exit? Or is there a certain starting point, and every exit must be reachable from that starting point?

P#23300 2016-06-20 14:43 ( Edited 2016-06-20 18:43)

If you're into this sort of thing, you may enjoy the Spelunker book


P#23302 2016-06-20 14:48 ( Edited 2016-06-20 18:48)

Maybe thinking it's better to make pre-defined maps that can then be put in random order? But that doesn't sound as "infinite" as I'd like...

This is basically what Spelunky does. While it's not "infinite", it's random enough that it can be played a ridiculous number of times and never feel the same.

Each level is a 4x4 grid of pre-defined 10x8 tile rooms. The level generator creates a traversable path through the level, then adds rooms that may or may not connect to that path in the empty spaces. Each of the rooms is chosen from a set of templates for that room's location. For example all rooms of one template would have reachable exits on the left and right. Each template then has variation in tiles that don't affect those exits (e.g. a two tile high wall that can be jumped over).

A more detailed explanation is here.

P#23310 2016-06-20 15:18 ( Edited 2016-06-20 19:18)

Heres a short video explaining the spelunky map generation

P#23355 2016-06-21 03:46 ( Edited 2016-06-21 07:46)

[Please log in to post a comment]