dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Ideas for speeding it all up

Hybrid View

  1. #1
    Please, Call Me Bob trogdor458's Avatar
    Join Date
    Aug 2006
    Location
    Pensacola, FL
    Posts
    915

    Ideas for speeding it all up

    Everything's working fine for now, and I'm actually proud of my progress, though I stop for a few days everytime I hit the slightest milestone



    The entire game relies a lot on my homemade physics system
    It may seem silly to use something homemade, but I honestly never figured out how to use a physics system I hadn't made myself, and I don't feel quite as accomplished either

    Also I need to be able to explain every cog in the machine down the road when I present this as a project

    Anyways, this is all fine and dandy for now, I can pump maybe a thousand particles into the room before things slow down, but the room itself ain't so big



    However, if all goes as planned, I'll be working on much larger terrains over the next few days, and I'm wondering if there are any tips on relieving the load?

    One example idea I thought of:
    Most of the particles are going to be temporary for cool explosions and such, and I could simply stop them from testing against any surface they couldn't possibly reach in their limited lifespan

    Do you know of anything that's particularly effective?

    EDIT: To be honest, I'm not sure if it'll slow down from the extra calculations
    It seems likely that a lot of the lag comes from simply rendering all the particles
    Last edited by trogdor458; 08-06-2009 at 01:49 AM.

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    I have not found anything faster then copyPixels so far. It can handle many thousands moving objects with pretty good speed. And of course, use AS3.

  3. #3
    Funkalicious TOdorus's Avatar
    Join Date
    Nov 2006
    Location
    Nijmegen, Netherlands
    Posts
    697
    Spatial indexing. Just a 2D grid alone will do wonders.

  4. #4
    Half Empty happinessSam's Avatar
    Join Date
    May 2003
    Location
    London
    Posts
    442
    Like Tonypa said, copyPixel is the way to go. -Prerendering all the possible particle states onto a sprite sheet before the game starts then copying off of that.

  5. #5
    Professional Flash Developer
    Join Date
    Aug 2007
    Location
    California
    Posts
    105
    You can even render them into an array of BitmapData frames directly from your current MovieClips. This is slightly slower than pure copyPixels from a sprite sheet (becaue array access takes some processor time), but it can really help solve the issues of moving everything to external sprite sheets.

    Once you have an array of BitmapData objects, you can simply assign them to the bitmapdata property of a Bitmap object in order and you get a clean, fast animated sequence.

  6. #6
    Please, Call Me Bob trogdor458's Avatar
    Join Date
    Aug 2006
    Location
    Pensacola, FL
    Posts
    915
    Thanks, for the info on processing graphics faster, I'll look into it
    But I checked, and it's the math slowing it down for now

    And the spatial indexing?
    From what I'm reading (I might have wrong idea), I'm not sure how well that would work
    At the moment I'm constructing this on the idea that you could run into any wall at any given point, so I don't run into some sort of glitches down the road

    The first thing I shall change is the order I do my checks in
    For some reason I calculate the intersection point of the two vectors before checking to see if the two vectors have a remote chance of intersecting

    I will want to see if their spaces even collide first before doing math to make things go faster

    Besides that though, what about grouping?
    Let's say you have 64 vectors
    What if you split that up into two groups of 32? and each group of 32 is two groups of 16? etc. etc.

    Best case scenario it would turn 64 checks into about 12, the improvement would be bigger for even larger maps (1024 becoming 20)
    Worst case scenario, if your guy just so happens to be spanning the entire map in one frame he's going so fast, it would turn 64 checks into 126

    This would be worth it for ginormous maps yes?

    And Tonypa, I have neglected it for awhile but I finally converted to AS3
    A lot easier than I thought it would be

  7. #7
    Senior Member
    Join Date
    Nov 2005
    Posts
    192
    use one bitmapData instead of 1000 sprites, if you aren't already. Draw all the particles on it with copy pixels, cache the rotations/angles of particles before hand

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center