A Python program simulates the flight of a cannonball. The program asks the user to press Enter
Question:
A Python program simulates the flight of a cannonball. 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.
Here is the code I have so far.
-------Code-------
from turtle import *
speed(0)
hideturtle()
penup()
vel = [8,25]
charge = 10
position = (-250, -200)
gravity = -1
input("Press enter to fire.")
goto(position)
dot(10,"black")
goto(xcor()+vel[0],ycor()+vel[1])
Cost management a strategic approach
ISBN: 978-0073526942
5th edition
Authors: Edward J. Blocher, David E. Stout, Gary Cokins