The program asks the user to press Enter to fire the projectile The cannonball is then drawn,
Question:
The program asks the user to press "Enter" to fire the projectile
The cannonball is then drawn, frame by frame, as it moves through a ballistic path.
Once a frame has been drawn do not erase it, we want an 'onionskin' drawing of the animation
The animation stops when the cannonball gets to a position where y is less than the starting y coordinate of the cannonball
You can choose the factors that control the trajectory (velocity vector, gravity strength, and initial position of the ball), but you need to balance them so the ball starts near the lower-left corner of the screen. reaches almost to the top of the screen, and is still on the screen when it stops.
How do I fix the problem to make it start at the bottom of the screen and move toward the top? How do I add more dots after it reaches it peak?
-----Code-----
from turtle import *
speed(0)
hideturtle()
penup()
vel = [8,25]
charge = 10
position = (-250, -250)
gravity = -1
while ycor()>position[1]:
vel[1] += gravity
goto(xcor() + vel[0],ycor() + vel[1])
dot(charge, "red")
dot(2, "black")
# this will create a trail of bullets from the cannonball
# check if it is still within the boundaries
if xcor() > 300 or xcor() < -300 or ycor() > 300 or ycor() < position[1]:
done()
done()
Cost management a strategic approach
ISBN: 978-0073526942
5th edition
Authors: Edward J. Blocher, David E. Stout, Gary Cokins