-
Script kiddie
[SHOWOFF] Super-fast mass collision and 'particles'
Thanks to the suggestions of board members here on FK (and especially iopred, who actually showed me the source to his particle handling engine), I've been able to boost Invasion to phenomenal speeds.
http://www.birchlabs.co.uk/Invasion5.swf
This is firing 100 arrows per second, and there are 100 troops on the battlefield. Doing this without BitmapData would run, I think, at less than 1 fps (especially in high quality mode). I get from 16 to about 25 (slows down as more arrows are released, speeds up again when the castle's reloading).
So, what do you think of the speed? I've still got to turn a couple of things into bitmaps, but besides that I've used every speed boost I could think of (and a few others that I'd been told).
-
god, so mne movie clips
Such little speed
I wonder where that thread went now, need to save cuz I can see its useful =)
grats man, hope the final product brings a couple of smiles ^^
Your skill in reading has increased by 1.
-
Senior Member
*jaw drops slightly. Very nice work. No real noticable slow down on my computer.
"If I have seen further it is by standing on the shoulders of giants." Isaac Newton
------------------------------------------------------------------------------
-
very cool...freaked me out when I refreshed it n suddenly it was night time
RipX
-
nice work....I;m getting between 22-25 fps .....are you still using the attachBitmap()/scrollRect combo for these?
EDIT: are you doing pixel-level collision detection using the hitTest bmp method?
paul.
-
Heli Attack!
Great work, you did it!
"Defend the Castle 2" looks to be a winner!
-
No speed loss, worked perfectly. Very nice indeed.
-
Style Through Simplicity
Good job mate. Glad to see you got it running smoothly. Looking forward to playing the finished game
Ali
-
Please, Call Me Bob
holy moses, that runs great. looks like you'll be able to pull out alot of neat tricks with such optimization
those knights never stand a chance
-
Hype over content...
Good work big V.
Looks like I've got a bit more to do on my shooter to compete with that
Squize.
-
Script kiddie
RipX, glad you appreciate the random backgrounds.
Pentru, yup, I'm using iopred's attachBitmap()-based engine to make the troops and arrows, then looping trhrough them and running scrollRect() to choose which frame they display (that's right, the arrows are bitmaps. No _rotation usage, I just drew a sprite sheet with every 5º that the arrow could rotate through, and used atan2() to choose which frame to set it on).
Not using pixel-level collision. What I'm doing is splitting the map up into 10 pixel wide sectors, and keeping an array of which troops are in which sectors. Then when the arrow is low enough to hit something, it'll kill the first element in the array of the sector it's in. No collision, loops, or clever maths required. Just craftiness.
Iopred, I think I'll work on 'Attack the castle 5' before 'Defend your castle 2' but you never know. Was this particle engine the one you used in Heli Attack 3?
At first I was using mr_malee's suggestion of getColorBoundsRect() to work out if it was worth checking for collisions that frame, but I lost a lot of fps by running constantly, so I ditched it.
Ways I can see to make this even faster:
Use less arrows and troops (duh!)
Turn the castle into a bitmap
Instead of using atan2() on the fly, make an array of pre-calculated results for it.
Use flipflopping for collision detection (but the arrows are already pretty inaccurate as it is, and the collisions are extremely fast anyway, so I'm not gonna try it).
-
Flash hates me.
23-26 fps here. Amazing work.
"wen i found my gerbil dead my other gerbil was eating it i just cried and screamed"
http://www.livescripts.net
--------------------------------------------------------------------------------
Last edited by some moderator : Today at 9:01 PM.
-
Script kiddie
Turns out pre-calculating the trigonometry makes it slower rather than faster. :/
-
Senior Member
Nice! Do you have a link to iopred's engine? I would like to do cool particle effects too.
-
Script kiddie
-
Senior Member
Thanks! I'll take a look at it.
-
Script kiddie
I bitmap-cached the static parts of the castle, and got rid of the collision bitmap I wasn't using (note how the Redraw Regions are no longer the entire screen now). This bumped the framerate up about 2-4 fps!
Last edited by VENGEANCE MX; 11-11-2006 at 08:40 PM.
-
Originally Posted by VENGEANCE MX
Use flipflopping for collision detection.....
can you explain that a bit?.....I think I heard of that before, but can't remember....thanks!
paul.
-
Pumpkin Carving 2008
Slightly varying FPS from 31.2 to 30.4. Amazing.
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
-
Script kiddie
Flipflopping is where you halve the number of collision checks you have to do by only checking half of the collisions on each frame. Like so:
PHP Code:
flipFlop = true;
collision = function() {
flipFlopStart = flipFlop;
for (var i in enemies) {
flipFlop = !flipFlop;
e = enemies[i];
if (flipFlop) {
// Check for collision
}
}
flipFlop = !flipFlopStart;
};
onEnterFrame = collision;
Or something along the lines of that. I may have made a mistake or two, but that's the general idea of how to go about skipping every second troop (another way to do it is to check all the collisions every two frames instead of half the collisions every frame, but the latter way spreads the processor load more evenly).
Also, something interesting: It was faster for me to attachBitmap() on the same depth rather than use attachBitmap() and scrollRect() when I was trying to change the frames the arrows were on. It might be something to do with how big my arrow sprite sheet was: http://www.birchlabs.co.uk/ArrowSpriteSheet.png :/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|