# General Advice - Procedurally Creating Platforms?

0 Favourites
• 18 posts
• So I'm wanting to make a game like Spelunky; a platformer that has randomly generated levels. So, in other words, the first time you start the game, there will be 3 platforms, then a long jump, and then some stairs. The next time you start the game, there might be some stairs leading up to a platform, then a long jump over to four other platforms. The third time you start the game, it creates a new random layout. I realize that something like this would have to be coded, as you would have to tell the system all the rules it would need to know to build a level. Example:

1. Platforms must be spaced between x and y pixels apart.

2. Platforms cannot be more than z pixels higher than the nearest platform (cause the character can't jump that high)

3. Platforms length minimum and maximum

4. Etc., Etc

So, here are my questions!

A) Is this type of game possible in Construct 2?

B) Is there a programming/scripting language in Construct 2?

C) If I can create a randomly generated level layout in an 2-dimensional array, how do I get Construct 2 to build that on-screen? For instance, the 1st 30x30 pixel block on the bottom left of the screen displays a platform sprite if Array[1,0] = "P", and then if Array[1,1] = "L", place a ladder sprite on top of the first platform space

(Am I making any sense here?? LOL)

Basically, can I make a platform game that randomly re-arranges the platforms according to certain rules each time you play it?

I would greatly appreciate any help or advice that anybody could give me!

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• A: yes

B: no

C: arrayat loopindex "x", loopindex "y" = "banana", system make banana at loopindex "x" *30, loopindex "y" *30.

No idea how you want to populate the array.

You can either:

B: use an algo, random(n) = this, do foo.

• Newt, thanks for your response. It's good to hear that this is possible.

Few more questions!

1) Sorry for the noob question, but I'm used to seeing array syntax looking like If ArrayName[x,y] = 8, Then Do Function_Name.

I see you use the term loopindex x and loopindex y. I'm not familiar with this term. Does it replace [x,y]? So instead of ArrayName[3,2], it becomes ArrayName loopindex 3, loopindex 2? Again, sorry, I'm probably misunderstanding what you are saying.

2) Your response looks suspiciously like code, but you say there is no programing language in Construct 2. Are you saying I will have to built and manipulate dozens of multi-dimensional arrays, built item and loot tables, and build a procedural level design engine - all through the event sheet drag and drop editor? Is this even practical? I imagine that would be very cumbersome...if it's even possible.

• To begin you would want to create a trigger such as start of layout, located under the system object. Then you would create a sub event under that, a nested loop. This would be a for loop, again located under the system, I would name it "x", as per my example. To nest it, add another subevent, another for loop, "y".

Then, once more you add a sub event under that, this will be a comparison.

The array object has one built in, or you can use the system compare.

Named for loops can be referred to in expressions as loopindex("loopname"). So if you input loopindex("x") in your comparison it will use the value of the current loop, 0,1,2,3,4, etc.

There are tons of examples that come with C2, and much more on the forums.

Might want to look around, its an excellent resource.

• Thanks Newt, I get what you're saying about the loop index now. It would be similar to

For x = 1 to 10 do

For y = 1 to 10 do

Array[x,y] = 0

Thanks for the help. <img src="smileys/smiley1.gif" border="0" align="middle" />   I'm still a little skeptical of doing all this through a drag-and-drop editor, but I'll look into some examples and see if I can get the hang of it. You don't happen to know of any examples that do something similar to what I'm talking about, do you? Anything that is procedurally generated actually - doesn't have to be a platformer... I've seen tons of examples on how to drag and drop platform sprites in the layout view to build a level, but I haven't seen any that touches upon building one in an array and then "printing" it to the screen...

• I think your issue right now is how to populate the list. The array object isn't set up to load from an external source.

random array

• Wow - AMAZING! That's exactly what I was looking for. I can now wrap my head around this. THANK YOU!!!

[How do I give +Rep on these forums?!]

• I think your issue right now is how to populate the list. The array object isn't set up to load from an external source.

random array

Excellent example newt.

• <img src="smileys/smiley4.gif" border="0" align="middle" />

Newt -This was so clear and concise, what a great answer.

• Thanks guys, glad I could help.

• Not like it hasn't been said, but excellent job newt, and its admirable how well you keep up with the questioner. Not this one, necessarily, just simply your commitment to general assistance.

• Thanks for sharing

• Here's a detailed look at how they generated the levels in spelunky

http://tinysubversions.com/spelunkyGen/

• That "random array" attachment is missing newt?

• Thats pretty old, but I think it went along the lines of looping over an array(for each), and setting the value to random().

Or this: