FRUIT CIRCLE PHYSICS
Features:
Click to add a fruit/ball. Make fruits fly around!
* watch the epic motion blur/movement fading effect as the fruits fly around
* toggle different rendering modes, such as rotated sprites (BitmapData.draw + Matrix), still sprites (BitmapData.copyPixels) and the movement fading (BitmapData.merge with multiplier 86 on a white 0xFFFFFFFF 640x430 bitmapData) and you can also show the collision circles
* change appearance of fruits (make all the same, randomize)
* and something I've never done before...save a screenshot directly from the Flash onto your computer! I've seen it be done before, so I researched it, and found out you could use the FileReference class to prompt a user to save a file to the user's computer, and then encode a PNG using PNGEncoder.
Algorithm optimization?
The algorithm is not optimized in any way, I simply looped through each circle twice, so if we have 100 circles, it's gonna do 10,000 checks (O(n^2)). I chose not to investigate ways to speed up the engine, as this is simply a toy and not some kind of big project that'll be needing great performance. But: I tried splitting up the stage into 10x10 small boxes, and for every box it'd only check collision inside those boxes, but I found the system to be acting weird when leaving a box, so inbetween each box there was a gap where the circles would fall, but it might be fixed if I would check for neighboring boxes.. but oh well, let's leave it as is, poor O(n^2) Also, if your computer starts to lag, simply just click 'Remove all', that should hopefully fix everything. Enjoy!
COMMENTS
blog comments powered by Disqus