How to create new Layouts in-game? (Rougelike Proc-Gen)

Just started using Construct 2? Post your questions here

Post » Fri Jun 19, 2015 2:43 am

I'm learning how to accomplish randomly generated layouts for my Rougelike project. I believe I can figure this out on my own.

However, I want the player to eventually leave that one "room" and advance to another room that is also randomly generated. I also want the previous room layout to be saved so they can return to it. I believe that the best way to do this is make every new room a new layout. How would I accomplish this though?
B
20
S
5
Posts: 108
Reputation: 1,473

Post » Fri Jun 19, 2015 3:59 am

There are many resources online describing algorithms to accomplish this kind of thing, and even a plugin or two if you search the add-ons forum.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Jun 19, 2015 6:13 am

I know it's just I've searched both resources and I couldn't find any on my own is the issue, hence the post :u
B
20
S
5
Posts: 108
Reputation: 1,473

Post » Fri Jun 19, 2015 8:01 am

https://www.scirra.com/forum/roguelike-plugin-c2-rot-js-interface_t118452

edit: this is just to generate a whole level, I guess it doesn't really answer your question. I'm not sure why you need a layout per room.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Jun 19, 2015 8:09 pm

Thanks! I spent the day reading that and although it has helped me along well in my progress of a Proc-gen system, it still doesn't answer my initial problem.

I know now that Creating a new layout for every new cell is not ideal. Rather I'd like to create a dictionary or array to do this instead. I still don't know how though. I know how to work with both when it comes to individual values but not complete game data.

My issue is: imagine that plugin generating a whole layout with rooms and such. Then at the end of said level a door opens up to a new "cell" that's completely regenerated and procedurally made. Now the player is required to go back to the first randomly generated room. This is what's stumping me.
B
20
S
5
Posts: 108
Reputation: 1,473

Post » Fri Jun 19, 2015 9:47 pm

The basic idea is:
The random numbers that you get from the random number generator depend on the initial number that is used to seed it. If you start with the same seed then you get the same sequence of "random" numbers every time.

You take a random number generator that lets you specify a seed. You give it a random seed and then generate your level. Generate a random x position for an object, generate a random y position for an object, generate a random number of enemies, etc. You save the seed for later. When you want to recreate that same level, you just use reseed the random number generator with the stored value and create the level again. Same random numbers = same layout.

Here's an example using the RandomPlus plugin:
randomSeedExample.capx
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,670


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests