monkeyonmars's Forum Posts

  • 2 posts
  • How to randomize without duplicates (Advanced Random permutation table feature) - LINK

    Thanks a lot! I'll take a look at it right away! :)

  • As the title says i have this scenario:

    I have a cards.json with an array of cards (array of objects). I want to generate 3 cards "opponents" to the player without the possibility to choose the same element.

    Example:

    cards.json

    [{ "id": 1, "name": "Goblin" }, { "id": 2, "name": "Another Goblin" }, { "id": 3, "name": "Healing Potion" }, { "id": 4, "name": "Ogre" }, { "id": 5, "name": "Healing Potion Super" }]

    I want to choose randomly three of this five elements and throw it to player without repetitive of the same object.

    Of course i'm doing a for loop in cards array and i know i can use round((random(0, max_size_of_array))), but how i can prevent the repetition?

    Thanks a lot for the help! :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You do not have permission to view this post

  • 2 posts