General Advice - Procedurally Creating Platforms?Forum Home > Construct 2 General > Construct 2 general
|Post Reply||Page 12>|
Topic: General Advice - Procedurally Creating Platforms?
Posted: 29 Jan 2012 at 5:56am
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!
Edited by Maximo - 29 Jan 2012 at 6:10am
|Post Options Quote Reply Posted: 29 Jan 2012 at 7:40am|
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:
A: add entries at startup
B: use an algo, random(n) = this, do foo.
|Post Options Quote Reply Posted: 29 Jan 2012 at 5:25pm|
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.
Edited by Maximo - 29 Jan 2012 at 5:30pm
|Post Options Quote Reply Posted: 29 Jan 2012 at 6:25pm|
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.
|Post Options Quote Reply Posted: 29 Jan 2012 at 6:39pm|
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. 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...
Edited by Maximo - 29 Jan 2012 at 6:42pm
|Post Options Quote Reply Posted: 29 Jan 2012 at 6:53pm|
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.
|Post Options Quote Reply Posted: 29 Jan 2012 at 7:06pm|
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?!]
Edited by Maximo - 29 Jan 2012 at 7:10pm
|Post Options Quote Reply Posted: 29 Jan 2012 at 10:27pm|
Excellent example newt.
|Post Options Quote Reply Posted: 30 Jan 2012 at 11:39am|
Newt -This was so clear and concise, what a great answer.
Edited by gazoogle - 30 Jan 2012 at 11:40am
|Post Options Quote Reply Posted: 30 Jan 2012 at 4:08pm|
Thanks guys, glad I could help.
|Post Reply||Page 12>|
|Forum Jump||Forum Permissions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum