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

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])

Step by Step Solution

3.37 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

from turtle import Set up the turtle screen Speed D hidet... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!