55 Condition Test

0 favourites
  • 7 posts
From the Asset Store
Soldiers` Test
$12.99 USD
A Construct version 2 & 3 "Stand-alone" RPG game with "In-Game Module" (IGM) integration.
  • Hi.

    I need to set a flag between 55 specific conditions.

    Thought about rolling a random number, such as int(random (0,55)), but that would not be fair since there would be many fractional values, so in essence occasionally some numbers would be favored.

    Thought about using Choose (a, b, c) since that gives equal chance to a, b, c, but could not find how to access it in the software? Does not seem to be under System.

  • It's an expression, not an action. So, for example, you'll set the value of a variable to choose(a,b,c).

    Using floor(random(55)) should give you what you want without favouring any numbers, though.

  • Thank you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • floor(random(55))

    secondd' <img src="smileys/smiley41.gif" border="0" align="middle" />

  • Would there be a more elegant solution other than designing 55 different if/then branches? With an array maybe? Instance variables off a spawner?

    Basically on Condition X (the rolled number from 0 to 55), I need to spawn specific objects for each number while randomizing their size and speed.

    I need to think on this some more.

    (It's late.)

  • Arrays are underutilized and very favorable for repetitive tasks.

    They can eliminate many logic steps.

    X=floor(random(55))

    array(0-54,0) stores 1st set of data for conditions 0-54

    array(0-54,1) stores 2nd set of data for conditions 0-54

    array(0-54,n) stores n set of data for conditions 0-54

    then using x as the condition variable...plug the values from array into appropriate conditions and spawnings etc...

    spawn array(x,0) Monsters at array(x,1) x axis and array(x,2) y axis with a speed of array(x,3)

    or random x,y, speed....

    spawn array(x,0) Monsters at floor(random(array(x,1)) x axis and floor(random(array(x,2)) y axis with a speed of floor(random(array(x,3))

    taking it one step further, the Monsters spawned could be stored in array(x,4) so that more than 1 type of monster could be picked.

  • Thank you, Kosiam.

    That's very interesting.

    So far I haven't used an array yet because I've been able to find simpler alternatives (such as spawning a random frame out of 54) for the same object for some variety, but I know eventually I'll have to get to arrays and that sounds like a very useful solution that affords a lot of complexity and control.

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