This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-12-02 10:38:39

mrwalker81
New Scratcher
Registered: 2010-11-03
Posts: 5

Help in experimenting with realistic gravity with a bouncing ball.

Currently, I've gotten this far. http://scratch.mit.edu/projects/mrwalker81/2190463

The ball bounces fairly accurately, taking into consideration gravity, momentum, and efficiency. My problem thus far is that when it bounces off of an object, it passes partially through it. This causes all sorts of problems.

My initial thought is that the broadcast and wait which is needed for passing the downward velocity variable, but I can't seem to get it working properly.

Offline

 

#2 2011-12-02 10:47:17

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Help in experimenting with realistic gravity with a bouncing ball.

I think it's the 'Wait 0.06 secs' in the else bit of the 'If touching colour blue'. Basically, this means that if it's not touching blue, it will only check if it is again after 0.06 seconds, meaning there'll be some delay. This can easily be worked around by simply putting the 'Change y by dnvelo' in the same forever.
Also, instead of broadcasting bounce, and then making another scripts for when the broadcast is received, why not just replace the broadcast with the set variable, because that broadcast is taking up time as well.
I'll just take a screenshot to show you what the new script should be...
EDIT: I've got the picture:
http://i39.tinypic.com/ad0pdi.png
Of course, this makes it a bit messy-looking as if it's not touching blue it only moves every 0.06 seconds, but I couldn't figure out how to change that, mainly because I didn't understand your other scripts.
smile

Last edited by RedRocker227 (2011-12-02 10:51:12)


Why

Offline

 

#3 2011-12-02 12:26:59

mrwalker81
New Scratcher
Registered: 2010-11-03
Posts: 5

Re: Help in experimenting with realistic gravity with a bouncing ball.

ahh.. you were correct, there was some delay coming from the broadcast event, switching it up to match with yours gave it less delay, and a quicker reaction to hitting blue.

Just about got it. Changed what you were talking about, and moved the incrementing timer to a separate script, didn't keep the if part waiting on the else part. Thanks a ton!

Offline

 

#4 2011-12-02 12:28:20

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Help in experimenting with realistic gravity with a bouncing ball.

Glad I could help!  smile


Why

Offline

 

#5 2011-12-02 13:07:25

Tbtemplex97
Scratcher
Registered: 2011-11-12
Posts: 100+

Re: Help in experimenting with realistic gravity with a bouncing ball.

i Have a few ideas, when it hits the floor, u could have a continouse bounce, and press up to make it bounce up?


Online Status: http://blocks.scratchr.org/API.php?action=onlineStatus&user=Tbtemplex97
Darkspace Coming Soon!, Try the Singleplayer Demo

Offline

 

#6 2011-12-02 14:07:07

mrwalker81
New Scratcher
Registered: 2010-11-03
Posts: 5

Re: Help in experimenting with realistic gravity with a bouncing ball.

Thanks tb, I like the idea. That would work. I hadn't thought to thoroughly yet about where to take the idea, although my initial thought was to make the floor an obstacle that took away a life. Perhaps make it a bit of a strategy game of bouncing off of various obstacles to get to a particular target.

Offline

 

Board footer