Anything equivilant to an 'OR' function?

sniffy176sniffy176 Member, PRO Posts: 48
Hi,

I'm creating a pinball-esque game, but instead of the plunger up the side I just want to spawn the ball from the middle of the table.

I want the ball to randomly start by accelerating in 1 of 2 possible directions.. 135 degrees or 25degrees.

Is there an easy way of doing this? Ideally there would be an OR function, so it could set it to:

accelerate in direction: 135 or 25 relative to scene etc.

I know I could probably set up a random number min1 max2 (x), and a game attribute boolean then an 'if x >=1 , boolean true, else false... etc and then

if boolean true
accelerate in direction 135
else
accelerate in direction 25

etc etc...


but that just seems an extraordinary amount of processing just to choose between 2 numbers?!

Any help in the right direction (pun intended!) would be greatly appreciated!

Sniffy176

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    In the accelerate direction use the expression editor and then select rand and use those two numbers.
  • sniffy176sniffy176 Member, PRO Posts: 48
    @FryingBaconStudios

    Aren't they a minimum and a maximum amount though?

    If I put random(25,135) the ball would be able to set off in any direction between those 2 numbers, whereas I want the ball only to be able to accelerate to 25 or 135 degrees. Not all points between.

  • MantoManto Member Posts: 796
    You could use this:
    25+random(0,1)*110
  • sniffy176sniffy176 Member, PRO Posts: 48
    @Manto1 - you are a genius!
    Thank you so much for that.
  • SocksSocks London, UK.Member Posts: 12,822
    Ideally there would be an OR function . .
    The 'otherwise' section is Gamesalad's 'or'.

    There are probably quite a few easy ways to select from a couple of numbers.

    -85 + (random(1,2)*110)

    135 / (random(0,1)*5.4)

    etc etc

    Or set up a table, stick your two numbers in separate columns or rows and select random column / row (1,2).

    There are probably dozens of other ways.
  • SocksSocks London, UK.Member Posts: 12,822
    EDIT

    Just seen Manto1’s post, that's the most elegant / straightforward way by far.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Oh yeah forgot min max. but I see I inspired an elegent solution.
  • RPRP Member Posts: 1,990
    What, no "E OR" function?
  • dmilinovichiiidmilinovichiii Member Posts: 620
    @Socks
    Actually, an "OR" can be made in GameSalad by changing the "All" to "Any" in a rule. Then if condition 1 "OR" condition 2 is true, the result will happen. Using the otherwise section is equivalent to "NAND" if the rule is set to "All" and "NOR" if the rule is set to "Any".
  • SocksSocks London, UK.Member Posts: 12,822
    @Socks
    Actually, an "OR" can be made in GameSalad by changing the "All" to "Any" in a rule. Then if condition 1 "OR" condition 2 is true, the result will happen. Using the otherwise section is equivalent to "NAND" if the rule is set to "All" and "NOR" if the rule is set to "Any".

    Good tips !

    In the context of how he was using 'or' ("accelerate in direction: 135 or 25 relative to scene etc") - I thought some clever use of 'otherwise' might be closer . . . . something like: if the rules for '25' are met then use '25' otherwise use '135'.

    ?
Sign In or Register to comment.