Alice Community how do i make a ball roll off a table and bounce on the ground

 how do i make a ball roll off a table and bounce on the ground
 bromsburg Guest   Status: Posts: n/a how do i make a ball roll off a table and bounce on the ground - 02-02-2009, 03: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
 Bouncing a ball
ottar9919
Guest

Status:
Posts: n/a
Bouncing a ball - 02-02-2009, 06: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
 Bouncing Ball example.a2w (202.7 KB, 117 views)

 bsmill04 Guest   Status: Posts: n/a 02-08-2009, 02:05 PM I would suggest the variable way. Decreasing by 1 instead of adding 5 different up 4 down 4 up 3 down 3.
haven812
Guest

Status:
Posts: n/a
12-10-2010, 11: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
 bounce.a2w (204.4 KB, 24 views)

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge