How do I set random objects to be visible each play?

0 favourites
  • 3 posts
From the Asset Store
This Student Workbook uses both Construct 3 & 2 encoding. It supplies client-side & php "back-end" encoding.
  • The title is not completely clear due charactere limitation, but what I want to do is:

    I will add lets say, 5 solid sprites, that are like walls, to my top down shooter, they will create some kind of barriers as game progresses making the player's dodging and movement limited.

    They will begin invisible and will become visible as the score increases. That I know how to do.

    But I want that, at each play, as the game has only one level, the order is randomized.

    So I was thinking about this:

    If score > X, set choose(wall1,wall2,wall3,wall4,wall5) visible

    This first part I get. But when it comes to setting the rest visible, when the first was random, is the problem. Should I create all possibilities independently? Like:

    If score > X² and wall1 is visible, set choose(wall2,wall3,wall4,wall5) visible

    If score > X² and wall2 is visible, set choose(wall1,wall3,wall4,wall5) visible

    And so on. And what is worse, is that I should all variables for each instance depending how many walls are up. For example:

    If score > X³ and wall1 and wall2 are visible, set choose(wall3,wall4,wall5) visible

    If score > X³ and wall1and wall3 are visible, set choose(wall2,wall4,wall5) visible

    So you can see how a pain that would be.

    What I wonder is if there is some easier way to do that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How about using an array and on the start of the layout, you put all of your wall's UID into the array? (use "For each" loop)

    See https://www.scirra.com/manual/108/array . If know the size of the array, you can pick a random index from the array with respect to its size and remove one randomized UID from the array. Then, pick a wall by its UID using UID number you acquired from the array. Now, set this picked wall to be visible and solid.

    Note: Also when you removed an element from the array, please check whether all the elements succeeding it are shifted up in index like in Linked List or not. I forgot whether this is the case or not. This is so that you can see whether you have to sort the array after removing an element or not.

    Do you follow or do you need further assistance?

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