How do I do Pseuo-Random levels? Random but no repetitions.

Get help using Construct 2

Post » Fri Oct 02, 2015 5:52 pm

Hello all! First time poster here and would like some help. :D

Let's say I have 20 levels at the moment and I want the game to randomly load another level after one is completed. BUT, I do not want it to repeat the same levels. There are several occasions where it would load the same level again, and it'll get repetitive for players.

Right now this is what I have:
Go to layout "Map "&floor(random(Number_of_Maps)+1)

This is the event for when you start a game, so it randomly loads a level from (1-Number_of_Maps), Number_of_Maps being a Global Variable I have. This event also happens once you complete a level, it randomly loads another. Once a level is loaded though, I want it to be out of the selection pool so that we don't return to it again.

If you curious what my game is, it is a top-down local multiplayer game with battle tanks.
Image

Thanks for helping me out! :)
B
12
S
4
Posts: 29
Reputation: 933

Post » Fri Oct 02, 2015 6:26 pm

Put all possible level numbers in an array. Then chose a random index of the array, go to the level of the array value and delete that index from the array (so it can't come up again when you select levels the next time).
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Fri Oct 02, 2015 6:51 pm

ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994

Post » Fri Oct 02, 2015 7:16 pm

Just a quick tip:
A great way to automatically generate a seed for your random number picker, is the time it takes the user to press the "Start button" at the beginning of the level.

Also wanted to say I love your explosion animations :3
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Oct 03, 2015 6:36 pm

Thank you everyone, I'll give it a go and see if it works.

jojoe wrote:Also wanted to say I love your explosion animations :3


Thank you :3
B
12
S
4
Posts: 29
Reputation: 933

Post » Sat Oct 03, 2015 7:20 pm

If you want to enhance it, make pieces of the tank that look broken, and add the "bullet" behavior with bounce enabled. Then On Created ---->set angle: int(random(0,360)).

They will fly apart,and bounce off solids when they spawn :D

Cool looking game, reminds me of Combat for the Atari 2600, The worlds very first home console "Bro-Game" in cartridge form.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Tue Oct 06, 2015 8:49 pm

jojoe wrote:If you want to enhance it, make pieces of the tank that look broken, and add the "bullet" behavior with bounce enabled. Then On Created ---->set angle: int(random(0,360)).

They will fly apart,and bounce off solids when they spawn :D

Cool looking game, reminds me of Combat for the Atari 2600, The worlds very first home console "Bro-Game" in cartridge form.


This is perfect!! Thank you! I just improved the animation sprites of my explosions and I wanted to add giblets. I just figured I'd just make them as animated sprites but your suggestion is much better. It'll make the destruction more physical since it'll bounce of the walls.
B
12
S
4
Posts: 29
Reputation: 933

Post » Sun Oct 11, 2015 1:08 am

I need to bump this since I don't want to make a new topic.

But I need help with this arrays. I'm still learning Consttruct 2 and haven't delved into learning arrays yet.
I've tried looking at tutorials but it still confused me.

How do I pull numbers from an array that will load a level? And how do I remove the number that has been used?
Basically, I don't know how to do random level loading without repetition.
B
12
S
4
Posts: 29
Reputation: 933


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, newt and 25 guests