[Solved] Pattern-based procedual generation

Get help using Construct 2

Post » Sun Jul 17, 2016 12:05 am

Hi Constructurerers! :D

Since quite a few hours now I'm trying to think about an algorythm, how to generate a dungeon with premade patterns the *best* way (there is no "best way", yes - but I want it to be as scaleable/ressource-friendly as possible ;) ).

The main problem might be, that I'm not exactly sure, what the correct name for such generator is, in english - things like "pattern based generation" or "dungeon generation with samples" doesnt showed me any usefull @ google.

What I want to achieve:
Sorry for the big picture; here's its direct link: http://proxy.wtf/_storage/construct2/screenshots/sketch_pattern_based_dungeongeneration.jpg
Image
When scene/level is starting, the generation-backend generates X (or less/more) rooms of an endless dungeon. The game starts when player wants to and ends when the player dies. A 8-way controllable player will be guided through a pixel-ish dungeon, filled with tons of monsters, secrets, chests, items and everything else, whats needed for a roguelike-hack'n'slash-RPG.
The biggest deal (for me) on this project, beside the art/gfx (because I suck in creating it like noone ever before :D), is the room-generation part.

In what I need help:
I need some advice in creating the generator. Thinking about an array, which stores informations about multiple, premade room-templates like: floor, walls, static elements; a random one is picked and "created" for the player. To make some pseudo-pseudo-code:

Generation is triggered; // Trigger = player.X < 40% of current room; or a trigger-zone which is beeing entered
Generator picks X; // X = a random number which represents a room-index
Informations from array are parsed to the tilemap;
Tilemap is beeing extended & parsed tiles are getting added;
Generation finished;

Because the player should be able to run backwards, I think, it would be the best to use a single tilemap which is getting bigger over time, instead of using multiple ones (if theres a more performance-friendly way, let me hear it!). Enemies, chests, dynamic objects, secrets and everything else should be added, too, when creating a room. Since Ild like to keep it on minimalistic hack'n'slay (not too heavy), many sprites are going to be generated each room (thinking about a minimum of ~10-15 objects and a maximum of ~20-25 sprites (or less, if the performance-impact would be too big in general... the targetted platform are mobile-devices)).

So, if anyone got improvements on my sketch, before I start to script it, please tell me here. I'm thankfull for every idea or tip to make my life easier!

Have a great weekend
Proxy
Last edited by Proxymity on Tue Jul 19, 2016 9:24 am, edited 1 time in total.
B
24
S
15
G
9
Posts: 118
Reputation: 6,864

Post » Sun Jul 17, 2016 3:11 am

Hey Proxy, is this dungeon intended to be seamless? The only thing I would worry about if I was you would be creating another room while there is a lot going on in the current screen because that is how you get jank.

Debug is your friend. Keep a close eye on how things are going as you implement it and it should give you a good idea of what is efficient and what isn't.
ImageImage
B
130
S
23
G
7
Posts: 1,078
Reputation: 13,280

Post » Sun Jul 17, 2016 3:19 am

GenkiGenga wrote:Hey Proxy, is this dungeon intended to be seamless? The only thing I would worry about if I was you would be creating another room while there is a lot going on in the current screen because that is how you get jank.

Debug is your friend. Keep a close eye on how things are going as you implement it and it should give you a good idea of what is efficient and what isn't.


Hi GenkiGenga,

yes, its intended to be seamless.

Im thinking about generating 3-4 rooms on start, and every time you reach the next one, an another is beeing genereted, if there isnt much action onscreen (thinking about making the generation dynamically; if not many objects are onscreen, the "generate-trigger" will be called; if there isnt such moment there is a hard-cap, when entering the last room created.... something like this might be possible somehow, if I debug it correctly, how you said ;) .


This is my current status on it (much more simpler than I thought at first, lol...):
http://proxy.wtf/_storage/construct2/capxs/PBDG.capx



This is a very quick and even more dirty version... rooms are stored in *.txt files; they are loaded into an array on start.... just figured out, that my experience in working with tilemaps isnt the best - after I got the generator done, Ill take a look into it. The "TilemapGenerator" layout + event sheet is provided by R0J0hound: span-class-posthilit-load-span-a-c2-generated-json-span-class-posth_p999114?#p999114 (will be removed, just used it for a fast tilemap JSON).

Cheers
Proxy
B
24
S
15
G
9
Posts: 118
Reputation: 6,864

Post » Sun Jul 17, 2016 4:28 am

It looks good to me. If you did find that it stutters a bit when you add in all your other gameplay elements on top you could think about creating the room a bit more slowly to lessen the load at the point of creation but it probably won't be necessary.
ImageImage
B
130
S
23
G
7
Posts: 1,078
Reputation: 13,280

Post » Sun Jul 17, 2016 5:42 am

GenkiGenga wrote:It looks good to me. If you did find that it stutters a bit when you add in all your other gameplay elements on top you could think about creating the room a bit more slowly to lessen the load at the point of creation but it probably won't be necessary.


Ill see it, when its time to script that part of the game :D

If I remind myself, Im going to report here, how performance is going (and may keep this *.capx here updated ;) ).

"Final" version (for now) for generating rooms:
http://www.proxy.wtf/_storage/construct2/capxs/PBDG_v2.capx


In the end, it was very simple... had too many too complex thoughts about what Im going to need & do... as always... thanks C2 for your simpleness! ;D

Best regards
Proxy
B
24
S
15
G
9
Posts: 118
Reputation: 6,864

Post » Sun Jul 17, 2016 2:09 pm

That's great man,

Looking forward to seeing some gameplay :)
ImageImage
B
130
S
23
G
7
Posts: 1,078
Reputation: 13,280

Post » Sun Jul 17, 2016 5:12 pm

Thanks for sharing your idea & capx here.
B
80
S
29
G
165
Posts: 233
Reputation: 88,617

Post » Sun Jul 17, 2016 6:20 pm

GenkiGenga wrote:That's great man,

Looking forward to seeing some gameplay :)


Thanks :D

This is how far I have come today/and yesterday..? :D ): http://www.proxy.wtf/_storage/construct2/PBDGv2 (Arrow Keys or Click/Touch; destroying barrels/enemies with holding space down :P).

Working with tilemaps is much easier than I thought...!

After spending hours trying to realize the idea of creating an additional array (1D), just for storing already calculated (by random) X,Y coords for each newly generated tilemap, at some point where I realized that this method is slower (I strongly think, thats just me, beeing unable to work with arrays that way :D ). than just spawning a sprite to check which tilemap tile Im getting back... if somone knows some improovements to this, Ild be the last who doesnt want them to hear :D

Cheers
Proxy
B
24
S
15
G
9
Posts: 118
Reputation: 6,864


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests