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
Step: 1
from turtle import Set up the turtle screen Speed D hidet...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started