User Tag List

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 30

Thread: Fastloops, Flash, HWA... is this possible?

  1. #1
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Fastloops, Flash, HWA... is this possible?

    So I have a game with 250-350 objects on the screen and I'm currently using a fastloop that loops through all of these objects and updates their position based on whether they are colliding with something or not.

    So my issue is that using normal MMF2dev, the game runs great up until the objects get over 200 (not the total game objects, just the objects being counted in this fastloop) Then I start to see framerate hits... This gets exponentially worse with each new object. So by 250 objects, the game has dropped 20fps and now plays at 40fps... By 260 objects, the game is in the 30fps range...

    When I test with with HWA and directx 9, I'm getting very minimal framerate increases... So I'm definitly sure that it's my fastloops causing the issue.

    I really would like this game to work in Flash, but I'm afraid it's not going to run at any sort of acceptable framerate. I'm also wanting to at least not have the framerate take such a hit in a normal exe or hwa exe when the object count climbs up to 250 or so. I can live with having max 300 of these objects on screen at once, but I want it to be fast framerates up to that point.

    I'm using the method of grouping the fastloop and activating/deactivating the group so that it's not running though every fastloop in my entire event list.

    But still, I'm needing the objects to update position with pixel perfect accuracy... so I sort of need to test every object on every loop. I was considering the ForEach object, but I hear it doesn't work with Flash?

    So what do you guys think? Should I try out the ForEach object for the windows/mac version and then recode a reduced/limited version using fastloops with the flash version?

    Is ForEach really going to help speed anything up anyway? I'm not really sure, since pretty much all of these objects need to have collision/movement updates on every loop.

  2. #2
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Re: Fastloops, Flash, HWA... is this possible?

    How about you explain *exactly* what you're doing and/or post a demo file?
    Moving objects and checking for collisions should not require fastloops, and would be much more efficient without them.

    It's best to work on the basis that fastloops should be used as a last resort, when there's no other viable alternative.
    Way too many people have started using fastloops indiscriminately, for just about anything involving multiple instances of a single object type.

  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Fastloops, Flash, HWA... is this possible?

    It's based on the block falling example by David Evans:

    http://www.konidias.com/blockfall_example.mfa

    This example only really shows the slowdown for me when the screen is almost entirely filled with blocks... I get a slowdown of about 14-17 frames. Which wouldn't be so bad by itself, but I have a game on top of this, with animated graphics and sounds and controls and effects, etc...

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Fastloops, Flash, HWA... is this possible?

    if you have 300 objects in a fast loop that runs 300 times, it will look at 90,000 comparisons. With the foreach object, it would reduce this to 300 comparison- it is indeed exactly what you want, but I can't be certain it will work in flash for you

    Keep in mind that comparing collisions of objects is a very expensive operation with high time complexity too, so having 90,000 comparisons looking at collisions with 300 other objects of size 32x32 pixels on their collision map- its easy to see how it can slow

  5. #5
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Fastloops, Flash, HWA... is this possible?

    Quote Originally Posted by Pixelthief
    if you have 300 objects in a fast loop that runs 300 times, it will look at 90,000 comparisons. With the foreach object, it would reduce this to 300 comparison- it is indeed exactly what you want, but I can't be certain it will work in flash for you

    Keep in mind that comparing collisions of objects is a very expensive operation with high time complexity too, so having 90,000 comparisons looking at collisions with 300 other objects of size 32x32 pixels on their collision map- its easy to see how it can slow
    Yeah, I figured as much. Thanks for the input though, I'm definitely going to check out the ForEach object as a replacement...

    I guess if ForEach won't work with Flash I will try a more limited fastloop version, but I still haven't tested the game in Flash yet... for some reason my Flash exporter isn't working.

  6. #6
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Fastloops, Flash, HWA... is this possible?

    Hmmm Having an issue with ForEach... I've tried to set it up the same as the fastloops, and it works for the blocks hitting the non-moving obstacle blocks, but the blocks just pass right through eachother and don't stack on eachother. I'm assuming because it's only working with one block at a time?

    Also I read that ForEach doesn't work with qualifiers... and this sort of requires them.

  7. #7
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Fastloops, Flash, HWA... is this possible?

    I've had the for each work with qualifiers, but maybe its different in HWA. But yes, it will iterate through them only one at a time. When you use the foreach object, by say "Run loop for all objects of type X", then use a condition saying "On loop for all objects of type X", it will run that loop once per each object of that type, narrowing the scope list down to a single instance each time. The order is the inverse of how they were created.

    So once a for each loop is set up with that single line of code, it should be exactly the same as if you did the fast loop method that looks like this:

    *Always:
    =Bad Guy: Set Flag 0 Off
    =Bad Guy: Set Flag 1 Off

    *Always:
    =Start Loop Pin Swords for (Number of Bad Guys) loops

    *On Loop: Pin Swords
    +Bad Guy's Flag 0 is Off?
    +Pick a Bad Guy at random
    =Bad Guy: Set Flag 0 On
    =Bad Guy: Set Flag 1 On

    *On Loop: Pin Swords
    +Bad Guy Flag 1 is On
    +{CONDITIONS}
    ={ACTIONS}

    *On Loop: Pin Swords
    =Bad Guy: Set Flag 1 Off




    As you can see thats an awful lot of code replaced by just the for each object. It also reduces the time complexity of your algorithm from a polynomial O(N^2) to a linear O(N). Unfortunately, ForEach is also extremely buggy and you'll need to mess with it quite carefully to get it to work. Be especially paying attention to the order of your conditions and putting events on seperate lines of code, ie don't put anything besides the "start foreach loop" on the foreach line, since afaik it doesn't interrupt the stack frame to run its loop (it executes it at the end of all events on that line, which is terribly odd and wrong)

    If you can figure out how to use it, its an amazing extension. But with the complication of flash, good luck :S

  8. #8
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Fastloops, Flash, HWA... is this possible?

    Quote Originally Posted by Pixelthief
    don't put anything besides the "start foreach loop" on the foreach line, since afaik it doesn't interrupt the stack frame to run its loop (it executes it at the end of all events on that line, which is terribly odd and wrong)
    As a rule, don't put any actions that trigger events (e.g. the built-in "start loop", or Start ForEach, etc) on the same line as anything else.

  9. #9
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Fastloops, Flash, HWA... is this possible?

    Well see the problem is that it's not going to let me detect collisions with instances of the same object... I can't do something like

    "for object A, if detector is overlapping object A"

    It'd be cake if the object wasn't landing on an instance of itself. But that's just how it has to be...

    The only way I can see to do this is with fast loops... I'm really stuck at the moment... I suppose I'll just have to tolerate a bit of slowdown and maybe scale back my game a bit to reduce it. :/

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Fastloops, Flash, HWA... is this possible?

    I learned a great trick from someone on this forum for making your game appear smooth even when there is drop from 60fps to 30fps.

    Limit the game to 30 fps in the the game options. 30 fps isn't too choppy, it appears quite smooth when it always runs this speed. (FYI, most televisions run at about 24fps and look smooth thanks to motion blur).

    This way your game won't appear to be slowing down until it dips below the 30 fps mark.

    My current flash game ForEach loops through 500 objects and still maintains 30fps.

Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Problem with Fastloops
    By Ls2 in forum Android Export Module Version 2.0
    Replies: 2
    Last Post: 19th May 2012, 08:20 PM
  2. A question about fastloops
    By kromblite in forum Multimedia Fusion 2 - Technical Support
    Replies: 16
    Last Post: 16th May 2012, 12:57 AM
  3. XNA and FastLoops
    By King_Cool in forum XNA Export Module Version 2.0
    Replies: 6
    Last Post: 26th January 2012, 08:08 AM
  4. Fastloops
    By Solgryn in forum Android Export Module Version 2.0
    Replies: 1
    Last Post: 4th August 2011, 07:28 PM
  5. Fastloops
    By MechatheSlag in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 21st June 2007, 09:22 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
  •