User Tag List

Results 1 to 7 of 7

Thread: Basic randomizing question

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Apr 2013
    Location
    Australia
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Basic randomizing question

    I have an enemy that shoots a projectile, and I'm wondering how to make it so that instead of just shooting every 2 seconds or so, it shoots randomly between say 2-4 seconds. Whats the best way of doing this?

    Thanks for any help

  2. #2
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleXNA Export Module
    ProdigyX's Avatar
    Join Date
    Jan 2011
    Posts
    1,197
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Set an Alterable Value to (Random([Number of Possible Seconds])*[Your Max Frame Rate])+[2x Your Max Frame Rate]. Have this AV always count towards 0. When it hits 0, fire the target and restart the counter.

    In the case of 60 fps, the formula should be (Random(3)*60)+120

    The possible values are

    (0*60)+120 = 120 (2 seconds)
    (1*60)+120 = 180 (3 seconds)
    (2*60)+120 = 240 (4 seconds)

    In the case of 50 fps, the formula should be (Random(3)*50)+100

    (0*50)+100 = 100 (2 seconds)
    (1*50)+100 = 150 (3 seconds)
    (2*50)+100 = 200 (4 seconds)

    etc...

  3. #3
    Clicker Multimedia Fusion 2

    Join Date
    Apr 2013
    Location
    Australia
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you! It works great!

    I have another question though, If I have more than 1 enemy, how do I individualize the firing for each one instead of all of them firing at the same time?

  4. #4
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleXNA Export Module
    ProdigyX's Avatar
    Join Date
    Jan 2011
    Posts
    1,197
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Its already setup to be individualized. Remember to fire when the AV = 0. Also, always subtract 1 from the AV.

  5. #5

  6. #6
    Clicker Multimedia Fusion 2

    Join Date
    Apr 2013
    Location
    Australia
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help guys!

  7. #7
    Clicker Multimedia Fusion 2

    Join Date
    Apr 2013
    Location
    Australia
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I noticed that, very cool. I also did end up using a matching fastloop in my code as my enemies consist of 2 objects (sprite and hitbox) and complications with the more basic code was causing some crazy bugs with monsters eventually spawning hundreds of bullets all over the place. Theres probably be a way to make the more simple code work with some effort and minor changes, but just putting in the match fastloop was an easy solution to guarantee each enemy is individualized.

Similar Threads

  1. Need help with Arrays (Basic question I guess ^^)
    By Gogeta in forum Multimedia Fusion 2 - Technical Support
    Replies: 15
    Last Post: 28th August 2012, 03:59 PM
  2. Quick Question - Basic Moving Platforms
    By mkj5025 in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 3rd March 2009, 01:48 PM
  3. Basic question about HWA
    By teddyq in forum Hardware Accelerated Runtime
    Replies: 6
    Last Post: 1st March 2008, 06:38 PM
  4. Basic Question - Vista compatible
    By txventure in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 23rd December 2007, 03:40 PM
  5. Very basic Moogame/Mooclick question
    By Taofeld in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 26th September 2007, 11:56 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
  •