How do I randomize images in a preset distribution?

Not favoritedFavorited Favorited 0 favourites
  • 2 posts
From the Asset Store
A template for creating sprite editing functionality, including selection, resizing, rotation, duplication and more
  • Hey everyone,

    I have the following scenario:

    I would love to create a randomizer for some images, that follows some preset rules. There is a certain amount of images on the screen. (5,6,7 whatever) which I would love to randomize via a button press.... either via set frame or set animation.

    The tricky part is that I would love to add some logic to each of this configurators. Something like One of the images has to be A, 2 of the images have to be B and the rest can be C to F.

    How can I tackle this best, so that it´s relatively easy to handle?

    Happy to hear your thoughts! :-)

    Thanks for the help in advance.

    Beaver

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could create the objects with one event, or just place them with the editor.

    Then with a second event you could set the frames.

    Maybe:

    start of layout
    For each sprite ordered by random(1)
    — compare: loopindex=0
    — — sprite: set frame to A
    — else
    — compare: loopindex<=2
    — — sprite: set frame to B
    — else
    — — sprite: set frame to choose(C,D,E,F)

    Or you could use an instance variable to mark the sprites as unset and have a series of events to pick a random instance of the unset ones, and set it and set a frame.

    A third way to look at it is to make a list with an array or text variable, and populate it with on A, two B’s, and n amount of a random cde or f’s. Then you’d shuffle them before setting the frames.

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