Procedural Level Generation

For questions about using Classic.

Post » Tue Jun 21, 2011 3:47 pm

Hello, again. I was wondering how one would make a procedurally generated level on loading the layout? I know there are many ways to do it, but I just cant think of any way of how it might work! I've looked it up on Google many times, but never found how it works.

Think about Towerclimb, for example. It's made to not be impossible, and has most of its items intelligently placed when you need them. I assume it creates in rows, but how does it determine what goes where and when?

Be as in-depth as you'd like, the more the better! (Just don't get to complex, please. xD)

(By the way, Labyrinth's level generation (for the One Buck challenge) was ENTIRELY random. It just placed blocks and made them overlap so that they form some sorta cave. If it wasn't possible, it was ditched and a new one was made. I know that's not proper, and that there has to be a better way to do it!)
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Tue Jun 21, 2011 4:21 pm

Prime numbers may be useful to you for repetition by the way, here's an excellent article with some good ideas and that will explain the concept better than I can!

http://designfestival.com/the-cicada-pr ... designers/
Image Image
Scirra Founder
B
124
S
37
G
25
Posts: 3,945
Reputation: 44,887

Post » Tue Jun 21, 2011 9:47 pm

Awesome, Ill keep that in my bookmarks. :)

Also, I'm making a dodge survival game for now, so I can apply this later :P
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Tue Jun 21, 2011 11:15 pm

Search the completed addons section for plugins by arsonide
He's got beyond awesome procedural generation stuff. Also, depending on your approach, if you need object memorization, or picking beyond construct's regular ability, the s plugin provides a lot of power in that regard at the expense of a steep learning curve.
You need to decide what type of procedural thing you want to do, like will it be like worms? Spore? Or towerclimb. You'd probably have a different approach, what did you have in mind.

You should always try tlo translate your words in to events or code if you get stuck. For instance
We want powerups to appear randonly for a player at random spots
[code:1oj4sjxw]If(random( 20)==5)
Create powerup at random(1000),random(1000)[/code:1oj4sjxw]

That means every tick there's a 1 in 20 chance of getting a powerup
That's not what we want tho, we don't want them to appear, but to be at the next part of the level, and go by distance from the lastpowerup, not time passed

Only if its further than some predetermined required distance:[code:1oj4sjxw]
If (distance(character.x,character.y,character('lastpowerupx'),character('lastpowerupy') is greater than character('requireddistance') [/code:1oj4sjxw]

Then create it off the screen on the rightside
[code:1oj4sjxw]-----create powerup at scrollxright+10, floor.y[/code:1oj4sjxw]

Set the new required distance randomly between 500 to 1500
Set lastpoiwerupx and y variables to the new powerup position
[code:1oj4sjxw]
-----character set pv 'requireddistance' to random(1000) +500
-----lastpowerupx = powerup.x
-----lastpowerupy= powerup.y[/code:1oj4sjxw]

You want to factor in current health, etc, add some pvs, and/or conditions, and/or actions, and you're on your way, when its not right because it appears too close to walls, and an extra condition that checks for that, or whatever., and keeping tweaking and adding until its where it needs to be.
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests