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

Report as inappropriate.

sp33dy
sp33dy presents ...

2012/2/8

GravityBalls

I needed to refresh myself with the laws of gravity. Here's a quick demo with a Ball that understands how to live in the real world.

Click run for the first 5 balls to start.

At any time, create a new ball and drop it on the background or just click away!!

Click the idle balls at the bottom to remove them.

Very simple, but the code should be interesting to people.

Do play with the gravity and kineticEnergyLoss variables!!

There are a couple of simple games that I'm thinking off with these!

3662 views / 605 in the last 7 days

Tags: mouse simulation physics demo with-source

open in greenfoot
Your browser is ignoring the <APPLET> tag.
A new version of this scenario was uploaded on Wed Feb 08 20:32:37 UTC 2012
danpostdanpost

2012/2/8

Nice! I would love to see them bounce off each other and the walls (real like)!
sp33dysp33dy

2012/2/8

Yes, there's a little bit of room to play with this. Thought people might like the example code. Especially with how i've implemented the act/gravity method. I've not commented the code because it should (hopefully) easy to read.
A new version of this scenario was uploaded on Wed Feb 08 21:10:16 UTC 2012 Source was missing! Knock yourself out.
darkmist255darkmist255

2012/2/8

I made something just like this a long while back (great minds think alike :D?), great work on it! Soccer balls > bouncy balls. Just in case you don't realize it, you can apply this code to ANY 2D side view game and it works really nicely since you only have to deal with horizontal stuff.

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

Who likes this?

No votes yet.