Alice Community Kick a Field Goal Game

 Kick a Field Goal Game
rshoe
Junior Member

Status: Offline
Posts: 12
Join Date: Sep 2013
Kick a Field Goal Game - 10-25-2013, 02:37 PM

I am working on Kick a Field Goal game from chapter 10. I know you have to use a variable when asking a question for angle and velocity, but I do not know how to take those variables and use the math code the book suggested. The code is used to move the football toward the field goal. I have added the code, but not sure if I am in the right ball park. If anyone has any suggestions please let me know.

Thanks;
Randy

This is text from the book:
When a field goal kicker kicks a football, the football moves through the air in a parabolic path because the motion of the ball is effected by gravity. As the ball travels upward, gravity slows it down until it stops (briefly) at its peak height. Then, the ball starts to come down and gravity speeds it up until it hits the ground. Two major factors influence the path of the ball: velocity (the speed of the ball) and the angle of the kick.

Ask the player to enter the angle of the kick (in degrees) and the initial velocity of the kick (in meters per second). Together, the velocity of the ball and the angle of the kick determine how long the ball will remain in the air (the “hang time”), how high the ball will go (the “peak height”), and how far the ball will go (the “range”). To compute the path of the football, first break the velocity down into two components:
horizontal (speed along the x-axis) and vertical (speed along the y-axis). The formulas for computing horizontal and vertical velocity are shown below. Note that the angle of the kick must be converted from degrees to radians.
horizontal Velocity = cos(angle of the kick, in radians) * initial velocity
vertical Velocity = sin(angle of the kick, in radians) * initial velocity

To compute the hang time, use the formula:
hang time = 2 * vertical Velocity / 9.8
Once you have the horizontal velocity, the vertical velocity, and the hang time, you can then animate the football’s motion by repeatedly computing the position of the ball (at each instant in time during the hang time ) and moving the ball to the new position at that time in the flight. For example, compute the position after 0.2 seconds has elapsed and move the ball to that position, then compute the position after 0.4 seconds has elapsed and move the ball to that position, then compute the position after 0.6 seconds
… and so forth. To compute the position of the ball (in x and y coordinates) after a specific lapse in time during the hang time, use the formulas:
x = horizontal velocity * elapsedTime
y = 0.5 *-9.8 * (vertical velocity * elapsedTime 2) + (vertical velocity * elapsedTime)
Sample test data: With an angle of 30 degrees and a velocity of 27 m/sec (about 90 ft/sec), the hang time should be approximately 2.8 seconds and the ball should travel about 66 meters forward from its original position on the ground.

Hints: We recommend using a loop that repeats while the elapsed time is less than the hang time. Each time the loop repeats, increase the lapsed time by a very small amount such as 0.2 seconds. Update the position of the ball each time through the loop, by moving the ball forward the change in x position and up the change in y position.
Attached Files
 Kick_Field_Goal.a2w (599.5 KB, 14 views)

 fourbros Senior Member     Status: Offline Posts: 476 Join Date: Nov 2011 Location: Right Behind You... 10-28-2013, 02:33 PM I don't even understand what the text is trying to say. Maybe someone like arty of jediaction could help you. My avatar is from the anime "Hyouka"....... You've probably never seen it, much less heard of it..... You should watch it........ print("Hello World") This is python code. Lakers > Clippers Vikings > Packers Cardinals > Brewers/Pirates/Cubs/Reds

 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     Alice Player and VR General Discussion     Questions and Comments     The Lounge