how do i make a random level selector

0 favourites
  • 2 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • hello,

    im trying to find a way to load random levels from my game to create a rogue-like kind of experience.

    i have hundreds of levels(as individual layouts) already designed and named, but i cant figure out how to choose a selection of those layouts and link them together for a playthrough.

    the only way that comes to mind is renaming all of them numerically and then generating random numbers to help select them (like making a "1-1","3-7" ect kinda naming convention or something)

    is there a way to randomly pick a layout based on some other property other than its name? or to generate a list of the layouts existing in your project? (and within a select folder?)

    thanks for your help!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can either manually add all the names of the layout in an array and pick one random name from the list, but that would be annoying to update and upkeep if you rename any layer. Or with your current convention if your levels never has 2 digit like 1-10, then you can use this formula.

    Go to Layout (by name) -> floor(random(X,Y)) & "-" floor(random(A,B))

    Where X is the minimum value of the number to the left and Y is the maximum + 1.

    A and B are the corresponding or X and B for the number to the left of your layout name.

    If your levels have 2 digit or more like said before 1-10, you will have to rename all of them adding a 0 if they are a single digit like 01-10 and use the zeropad in the formula.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)