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

#1 2010-08-24 12:28:50

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Realistic Marble Ball Physics?

I'm making a marbles-like game in which you drag your mouse on the screen and shoot a marble ball, trying to get it into the hole at the end of the level. There'll be walls and other marbles in your way. I already used step velocity rather than x velocity + y velocity. How can I make it so the ball will bounce off other marbles and walls in a realistic way?


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#2 2010-08-24 13:26:39

samurai768
Scratcher
Registered: 2009-07-21
Posts: 1000+

Re: Realistic Marble Ball Physics?

Make sure to use directional values, and when it hits a wall use this script:

if touching wall?
Point in direction (direction) - 180)


Try to figure out the rest. I hope that helped!  smile

Offline

 

#3 2010-08-24 13:31:15

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Realistic Marble Ball Physics?

samurai768 wrote:

Make sure to use directional values, and when it hits a wall use this script:

if touching wall?
Point in direction (direction) - 180)


Try to figure out the rest. I hope that helped!  smile

That doesn't work on the left wall.


60 second rule must die. now.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#4 2010-08-24 16:14:52

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Realistic Marble Ball Physics?

samurai768 wrote:

Make sure to use directional values, and when it hits a wall use this script:

if touching wall?
Point in direction (direction) - 180)


Try to figure out the rest. I hope that helped!  smile

That only half works- it makes the marble bounce back the way it started.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#5 2010-08-24 16:20:28

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: Realistic Marble Ball Physics?

ScratchReallyROCKS wrote:

samurai768 wrote:

Make sure to use directional values, and when it hits a wall use this script:

if touching wall?
Point in direction (direction) - 180)


Try to figure out the rest. I hope that helped!  smile

That doesn't work on the left wall.


60 second rule must die. now.

It should work for both walls if any.
And you probably need to add a "Move 10 steps" after the script just to make sure it comes off the wall when it turns around.

Offline

 

#6 2010-08-24 23:12:52

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Realistic Marble Ball Physics?

you need 2 formulas for horizontal and vertical bounces in Scratch...
direction * (-1)
(180) - direction

http://scratch.mit.edu/projects/Locomule/709464

Last edited by Locomule (2010-08-24 23:15:33)


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#7 2010-08-25 06:01:19

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Realistic Marble Ball Physics?

If all walls are vertical or horizontal, it's pretty easy.  If you have slanted walls, it gets much more complicated. 

For vertical walls, the bounce direction is (0 - direction)

For horizontal walls, the bounce direction is (180 - direction)

For slanted walls, see my Marble Roll Kit project
http://scratch.mit.edu/projects/Paddle2See/800850

Oops, I see that Locomule gave pretty much the same exact answer previously  smile


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#8 2010-08-25 11:27:58

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Realistic Marble Ball Physics?

Now we call that ninja'd lol. But you are being kind, I've seen your pinball projects, awesome! Guess I missed the marble roll kit, have to check that out too.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#9 2010-08-25 11:43:25

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: Realistic Marble Ball Physics?

Wait, you will need to explain a bit more about your project.
I thought it was flat and looking down at it, but it could be vertical and looking at it from a side or even sort of 3D

Offline

 

#10 2010-08-25 12:39:37

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Realistic Marble Ball Physics?

colorfusion wrote:

Wait, you will need to explain a bit more about your project.
I thought it was flat and looking down at it, but it could be vertical and looking at it from a side or even sort of 3D

You were right the first time.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#11 2010-08-25 23:28:05

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Realistic Marble Ball Physics?

Bump


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#12 2010-08-26 23:50:26

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Realistic Marble Ball Physics?

bump? no comments on the stuff posted so far?


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

Board footer