Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
how do i make a ball roll off a table and bounce on the ground
Old
bromsburg
Guest
 
Status:
Posts: n/a
Default how do i make a ball roll off a table and bounce on the ground - 02-02-2009, 02:02 PM

while the ball is bouncing, i want to make it come to decrease the height of the bounce before coming to a rest
   
Reply With Quote
Bouncing a ball
Old
ottar9919
Guest
 
Status:
Posts: n/a
Default Bouncing a ball - 02-02-2009, 05:15 PM

There are two ways you could do this.

One way is to have the ball move up, say 5 meters, and back down 5 meters. Then make it move up and down 4 meters, and 3 meters, and so on.

The other way is to make a number variable(lets call it X). In a loop, put "ball move up X meters" and "ball move down X meters". After that, put in "variable X decrement by 1". Loop it X amount of times.

Here is an example of both ways:
Attached Files
File Type: a2w Bouncing Ball example.a2w (202.7 KB, 117 views)
   
Reply With Quote
Old
bsmill04
Guest
 
Status:
Posts: n/a
Default 02-08-2009, 01:05 PM

I would suggest the variable way. Decreasing by 1 instead of adding 5 different up 4 down 4 up 3 down 3.
   
Reply With Quote
Old
haven812
Guest
 
Status:
Posts: n/a
Default 12-10-2010, 10:27 PM

Another way to achieve the bouncing effect is to insert a recursive method. Create a method named bounce in the object you want to bounce with the following number parameters- startHeight, and numberOfBounces. In the method insert the following, replacing ball with the object you want to bounce-
Code:
if numberOfBounces > 0
ball move up startHeight meters, style end gently, duration = startHeight/4 ball move down startHeight meters, style begin gently, duration = startHeight/4 ball.bounce(startHeight=startHeight*0.75, numberOfBounces=numberOfBounces-1)
Else
Do Nothing
Now you can call the bounce method any time, inserting the number of meters the ball starts to bounce at, and the number of bounces that the ball should bounce. I also attached an example of this using a basketball.
Attached Files
File Type: a2w bounce.a2w (204.4 KB, 24 views)
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2018, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.