HOME | DD

JohnJensen β€” Fruit Circle Physics!

Published: 2012-02-19 02:19:49 +0000 UTC; Views: 17444; Favourites: 84; Downloads: 939
Redirect to original
Description 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. 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... unless...I split up everything into small boxes, and-- well..no I'm not going to look into that )
* Fixed a bug where if you turned fruits off, then fruits on again the collision circles will still be shown.
Related content
Comments: 55

79089 [2015-03-11 16:23:46 +0000 UTC]

Filled my screen with fruits that (WERE ALL OVER THE) screen.

πŸ‘: 0 ⏩: 0

kaydothehusky [2014-11-27 11:13:38 +0000 UTC]

This is what next gen gaming is. *o*

πŸ‘: 0 ⏩: 0

DiamondStar8901 [2013-12-16 18:08:42 +0000 UTC]

i think i broke it. its stuck in an infinity loop of add 10s

πŸ‘: 0 ⏩: 0

ThousandWordsToSay [2013-06-02 16:06:40 +0000 UTC]

are mushrooms really fruits? huh... oh well *throws another*

πŸ‘: 0 ⏩: 0

Kitmit [2013-04-17 15:41:58 +0000 UTC]

Can I just say that I love this?

πŸ‘: 0 ⏩: 1

JohnJensen In reply to Kitmit [2013-04-17 18:34:37 +0000 UTC]

Yes, and I can say: Thanks!

πŸ‘: 0 ⏩: 0

Queen-of-Hearts-0811 [2012-08-10 01:42:46 +0000 UTC]

this is really cool what program did you use?

πŸ‘: 0 ⏩: 1

JohnJensen In reply to Queen-of-Hearts-0811 [2012-08-10 09:04:34 +0000 UTC]

Adobe Flash CS5.5

πŸ‘: 0 ⏩: 1

Queen-of-Hearts-0811 In reply to JohnJensen [2012-08-10 13:47:00 +0000 UTC]

nice shading and coding

πŸ‘: 0 ⏩: 0

GreekFellows [2012-05-12 02:29:55 +0000 UTC]

how did you make the screen shot part?

πŸ‘: 0 ⏩: 1

JohnJensen In reply to GreekFellows [2012-05-12 09:55:15 +0000 UTC]

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 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

πŸ‘: 0 ⏩: 1

GreekFellows In reply to JohnJensen [2012-05-12 10:18:26 +0000 UTC]

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.

πŸ‘: 0 ⏩: 0

BunnieXQueen [2012-04-24 07:53:24 +0000 UTC]

FRUUUUUIIIIT

πŸ‘: 0 ⏩: 0

o0Bragger0o [2012-03-14 22:40:39 +0000 UTC]

How do you make the shadow thing?

πŸ‘: 0 ⏩: 1

JohnJensen In reply to o0Bragger0o [2012-03-14 22:47:52 +0000 UTC]

I used BitmapData's merge function, which merges two bitmaps together. In this case I had a white 640x480 bitmap that I merged slowly together with the 640x480 display bitmap by a specific amount every frame

πŸ‘: 0 ⏩: 1

o0Bragger0o In reply to JohnJensen [2012-03-17 13:37:25 +0000 UTC]

Too complex for me...

πŸ‘: 0 ⏩: 0

yurionna [2012-02-26 05:23:46 +0000 UTC]

Although it's a simple idea, the dizzy bluriness they make as they fly and bounce around makes it pretty addictive

πŸ‘: 0 ⏩: 1

JohnJensen In reply to yurionna [2012-03-14 22:48:05 +0000 UTC]

Yeah, it really is. XD

πŸ‘: 0 ⏩: 0

khoi98 [2012-02-21 12:00:47 +0000 UTC]

LOL/// It's somewhat addictive.. .but not highly/// but AWESOME!

πŸ‘: 0 ⏩: 0

KahzeArt [2012-02-21 00:41:21 +0000 UTC]

mushrooms aren't a fruit

πŸ‘: 0 ⏩: 1

JohnJensen In reply to KahzeArt [2012-02-21 07:35:17 +0000 UTC]

read the first line of the description maybe?

πŸ‘: 0 ⏩: 1

KahzeArt In reply to JohnJensen [2012-02-21 08:16:39 +0000 UTC]

oop

πŸ‘: 0 ⏩: 0

GreekFellows [2012-02-20 10:31:47 +0000 UTC]

cool physics manipulation i like your techs.

πŸ‘: 0 ⏩: 0

krangGAMES [2012-02-20 09:35:40 +0000 UTC]

I love this

πŸ‘: 0 ⏩: 1

JohnJensen In reply to krangGAMES [2012-02-23 12:41:06 +0000 UTC]

Thanks! :D I knew I'd seen your name somewhere, from that Nyan Cat Fly game somewhere on the net.

πŸ‘: 0 ⏩: 1

krangGAMES In reply to JohnJensen [2012-02-23 12:50:20 +0000 UTC]

Haha, that would be it! Good eyes ^_^

πŸ‘: 0 ⏩: 1

JohnJensen In reply to krangGAMES [2012-02-23 19:45:51 +0000 UTC]

This requires further study.

πŸ‘: 0 ⏩: 0

NOADROW [2012-02-19 19:32:20 +0000 UTC]

THAT IS ....
AWESOME!!!!!!!!!!!!!!!

πŸ‘: 0 ⏩: 0

Ohblon [2012-02-19 17:15:17 +0000 UTC]

This one made me dizzy @@

πŸ‘: 0 ⏩: 0

akleski [2012-02-19 15:58:09 +0000 UTC]

pretty awesome really nice physics - love the trajectory when u shoot 10 or more of them high up above the white screen

πŸ‘: 0 ⏩: 1

JohnJensen In reply to akleski [2012-02-23 12:39:04 +0000 UTC]

thanks! haha yeah, that's pretty fun. xD

πŸ‘: 0 ⏩: 0

Arsehole [2012-02-19 15:53:20 +0000 UTC]

hehehehehe funnn. althought... methinks if you had cute animals insted it would be more popular!

πŸ‘: 0 ⏩: 1

JohnJensen In reply to Arsehole [2012-02-19 16:01:54 +0000 UTC]

Correct, but I'd feel too mainstream if I did that.

πŸ‘: 0 ⏩: 1

Arsehole In reply to JohnJensen [2012-02-19 16:02:55 +0000 UTC]

...hmm i guess. definatly dont do it with pokemon or something then

πŸ‘: 0 ⏩: 1

JohnJensen In reply to Arsehole [2012-02-19 16:05:14 +0000 UTC]

haha that'd be even worse. XD

πŸ‘: 0 ⏩: 0

T4un [2012-02-19 15:51:17 +0000 UTC]

nice work

πŸ‘: 0 ⏩: 1

JohnJensen In reply to T4un [2012-02-19 16:00:20 +0000 UTC]

thanks!

πŸ‘: 0 ⏩: 1

T4un In reply to JohnJensen [2012-02-19 20:20:20 +0000 UTC]

You are welcome

πŸ‘: 0 ⏩: 0

JaneFox [2012-02-19 09:52:33 +0000 UTC]

So cool

πŸ‘: 0 ⏩: 1

JohnJensen In reply to JaneFox [2012-02-19 13:41:45 +0000 UTC]

Thanks a lot! :D

πŸ‘: 0 ⏩: 0

haloflooder [2012-02-19 07:35:31 +0000 UTC]

Found bug. When you decheckify show fruits and check it again, circles doesn't go away.

Anyways, this flash toy is pretty cool.

πŸ‘: 0 ⏩: 2

JohnJensen In reply to haloflooder [2012-02-19 13:38:00 +0000 UTC]

Well, I was aware of it, but I just left it in until someone complained/noticed, but it's fixed now.

Also thanks!

πŸ‘: 0 ⏩: 0

luca0483 In reply to haloflooder [2012-02-19 12:59:20 +0000 UTC]

it aint a bug. when you dechecks "show fruits", the program automaticly checks "show collision circles".
to remove circles decheck "show collision circles".

πŸ‘: 0 ⏩: 2

haloflooder In reply to luca0483 [2012-02-19 15:49:13 +0000 UTC]

He fixed the bug. That box wasn't there before. It magically appeared after I told him about the bug. Derp.

πŸ‘: 0 ⏩: 0

JohnJensen In reply to luca0483 [2012-02-19 13:41:33 +0000 UTC]

true stuff, thanks for sticking up. But I updated the game and made it so that when you check fruits again it'll de-check collision circles. Let's hope somebody doesn't complain about when having both fruits on and circles on, then when turning fruits off and then on again the circles will be gone

πŸ‘: 0 ⏩: 1

luca0483 In reply to JohnJensen [2012-02-19 13:49:10 +0000 UTC]

epic danish funny thinking

πŸ‘: 0 ⏩: 0

KnebulaNight [2012-02-19 06:29:16 +0000 UTC]

AGH MAN, ITS TOO HARD.

πŸ‘: 0 ⏩: 1

JohnJensen In reply to KnebulaNight [2012-02-19 13:37:09 +0000 UTC]

damnit Knick, you're too used to me uploading hard games

πŸ‘: 0 ⏩: 1

KnebulaNight In reply to JohnJensen [2012-02-19 17:22:21 +0000 UTC]

;D

πŸ‘: 0 ⏩: 0

ClearFog [2012-02-19 02:50:53 +0000 UTC]

Software?

πŸ‘: 0 ⏩: 1


| Next =>