User Tag List

Results 1 to 5 of 5

Thread: Random Number Question

  1. #1
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    scottige's Avatar
    Join Date
    Jul 2006
    Location
    Scotland
    Posts
    411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random Number Question

    This is probably a silly question and something obvious I'm missing but here's my issue.

    I have various pads on my game that an enemy moves over.
    When it hits it it changes direction.

    I assign a number to an alt value Random(3)+1 to get a random number between 1 and 4

    One of the pads is 4 way so that's not an issue with the above method.

    My problem is, I need to find a fairly easy method to pick certain numbers.

    For example one of the pads in a corner is down and left only.
    For this I would only want to set the alt value to 3 or 4.

    A more difficult 1 would be a left or right pad.
    I would need to set the alt value to 1 or 3.

    I have a long winded version with a lot of events that basically keeps re rolling if it lands on a number I don't want.

    I was just wondering if there was an easier way?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Number Question

    Actually Random(3) + 1 gives either 1,2 or 3. Random(4) + 1 is what you want

    * Enemy collides with PadDownLeft
    - Set value to 3 + Random(2)
    [color:#009900]This will set the value to 3 or 4.[/color]

    * Enemy collides with PadLeftRight
    - Set value to 1 + (2 * Random(2))
    [color:#009900]This will set the value to 1 or 3.
    The alternative results are:
    a: 1 + (2 * 0) = 1
    b: 1 + (2 * 1) = 3 [/color]

  3. #3
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    scottige's Avatar
    Join Date
    Jul 2006
    Location
    Scotland
    Posts
    411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Number Question

    Ah great!

    Thanks.

    I should be able to tweak that for all the pads.

  4. #4
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    scottige's Avatar
    Join Date
    Jul 2006
    Location
    Scotland
    Posts
    411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Number Question

    Sorry, trying to get to grips with these random numbers .

    Would 1+(3*Random(2)) give me 1 or 4?

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,366
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)

    Re: Random Number Question

    Why don't you test it yourself?

    Here is the possible results:

    a: 1 + (3 * 0) = 1
    b: 1 + (3 * 1) = 4

    So yes, it will be either 1 or 4.

Similar Threads

  1. Getting a random number between a negative and positive number
    By D_Light in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 9th January 2013, 10:51 PM
  2. Spread random number?
    By ratty in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 4th August 2012, 04:36 PM
  3. Generate a random number
    By LemonyLime in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 11th May 2012, 03:37 PM
  4. Random number
    By Mayfly in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 27th August 2008, 11:36 AM
  5. Random Number Gen
    By mee in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 7th February 2007, 09:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •