This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

sp33dy
sp33dy presents ...

2012/4/24

Realistic Balls

Found a very interesting Flash article and thought I'd borrow the effect. Will publish source code when ready. Just thought I'd post something up.

F1 - Turn on ball boundary's (White - AlphaMasked, Blue - Simple skin)
F2 - Turn off ball boundary's
F5 - Stop movement
F6 - Start movement

5729 views / 1040 in the last 7 days

8 votes | 0 in the last 7 days

Tags: simulation physics demo with-source balls bouncing

open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on Sun May 13 19:54:19 UTC 2012 Ok, not had a chance to put light source in yet; therefore I'll post up the rough and ready code.
A new version of this scenario was uploaded on Sun May 13 21:41:09 UTC 2012 Added the alpha mask code. Do you see the difference between the two sets?
A new version of this scenario was uploaded on Mon May 14 18:55:33 UTC 2012 Added code to ensure balls are added into space and are shown on load (rather than start). There is a known problem in which balls collide and pin against each other. This is when three collisions or more occur at the same time. I will look and fix this soon. Time for tea.
SpilliSpilli

2012/5/15

This is cool, I'd recommend adding some type of intersection depth code which will push the balls back when intersection occurs because sometimes the balls fuse together.
SpilliSpilli

2012/5/15

This is cool, I'd recommend adding some type of intersection depth code which will push the balls back when intersection occurs because sometimes the balls fuse together.
sp33dysp33dy

2012/5/15

Thanks Spilli, thats what I plan today. Add code to move balls back to when they actually hit and prioritize the collision order. This should then ensure the balls never cling to each other. I'm also just putting a movable light source in and considering how to put ball reflections into a ball!
A new version of this scenario was uploaded on Tue May 15 19:01:02 UTC 2012 I've cleaned up some of the method overrides in the AlphaMasked & Skinned classes. I've also hardwired a rotate to the balls for now. This is in preperation of spin. F1 - Show boundarys F2 - Hide Boundarys F5 - Stop movement F6 - Start movement
A new version of this scenario was uploaded on Wed May 16 14:42:22 UTC 2012 Clingy ball syndrome fixed. Light actor added. Next is to add light spot and shadow to each ball based on distance and direction from light.
A new version of this scenario was uploaded on Wed May 23 22:26:11 UTC 2012 Had 5 mins to mess around with circular gradient fills tonight. Looks like the lighting is simple to perform. Drag the light source around (the yellow star).
MorranMorran

2012/11/20

As the ball rolls, the ball images act like they were in 3D and not 2D. How did you get the Ball images to look 3D?

See all comments

Want to leave a comment? You must first log in.

Who likes this?

lordhershey birdy JetLennit Moritz Antonio Spilli marcelo_japa SPower