deviant art

Deviant Login Shop  Join deviantART for FREE Take the Tour
[x]
Download File
SWF, 39.1 KB
more ▶

More from *JohnJensen

Featured in Groups:

Details

February 18, 2012
39.1 KB
640×480
Sta.sh
Link
Thumb

Statistics

Comments: 50
Favourites: 61 [who?]

Views: 1,833 (13 today)
Downloads: 27 (0 today)
[x]
:iconjohnjensen:
Before anyone says anything - yeah, I know some of them aren't fruits. :|

ALRIGHT:

So I found this spritesheet by ~Ails and I thought I was gonna make some sort of RPG game outta it, but then I found mysef playing around with ball physics and these fruits. :lol: And so I just added more features, and boom...the result became this.

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!


EDIT #1 (19 feb 2012)
* Added so that when you aim, a blue line with a ball at the point the circle touches the ground (like in Skyward Sword =0) will show you the path the fruit will fly until it hits the ground if not hit by any other fruits. (Making a path which includes what'll happen when the fruit flys around and touches other fruits will kill your computer... :paranoid: unless...I split up everything into small boxes, and-- well..no I'm not going to look into that :shakefist:)
* Fixed a bug where if you turned fruits off, then fruits on again the collision circles will still be shown.
Add a Comment:
 
love 0 0 joy 2 2 wow 1 1 mad 0 0 sad 0 0 fear 0 0 neutral 1 1
:iconkitmit:
*Kitmit Apr 17, 2013  Hobbyist Digital Artist
Can I just say that I love this?
Reply
:iconjohnjensen:
Yes, and I can say: Thanks!
Reply
:iconqueen-of-hearts-0811:
~Queen-of-Hearts-0811 Aug 9, 2012  Hobbyist General Artist
this is really cool :) what program did you use?
Reply
:iconjohnjensen:
Adobe Flash CS5.5 :)
Reply
:iconqueen-of-hearts-0811:
~Queen-of-Hearts-0811 Aug 10, 2012  Hobbyist General Artist
nice shading and coding
Reply
:icongreekfellows:
~GreekFellows May 11, 2012  Student Digital Artist
how did you make the screen shot part?
Reply
:iconjohnjensen:
I used a FileReference to save a ByteArray created by the PNGEncoder class of the bitmapdata I'm using to display the scene.

hud.screenshot.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void
{
     var ba:ByteArray = PNGEncoder.encode(displayBitmapData);
     var fileReference:FileReference=new FileReference();

     fileReference.save(ba, "rename_me.png");
});


Also if you're not using a bitmap to render your scene (which I've started always doing, since it's faster =p atleast performance critical games) you could simply create a new BitmapData instance, and then draw() the stage onto it, and then save that instance as a screenshot
Reply
:icongreekfellows:
~GreekFellows May 12, 2012  Student Digital Artist
alright.
i always use graphics to render my stuff, which runs smooth and it's best quality.
my frame rate is always 60 or 120, so using bitmap having to draw every time, every pixel is kind of harsh.
anyway thanks.:)
Reply
:iconbunniexqueen:
~BunnieXQueen Apr 24, 2012  Hobbyist Traditional Artist
FRUUUUUIIIIT :D
Reply
:icono0bragger0o:
~o0Bragger0o Mar 14, 2012  Student Digital Artist
How do you make the shadow thing?
Reply
Add a Comment: