Question: [ 3 pts ] Enhance the hit _ the _ target.py program that you saw in the class exercise so that, when the projectile misses
pts Enhance the hitthetarget.py program that you saw in the class exercise so that, when
the projectile misses the target, it displays hints to the user indicating whether the angle andor
the force value should be increased or decreased. For example, the program should display
messages such as 'Try a greater angle' and 'Use less force.
# Hit the Target Game
import turtle
# Named constants
SCREENWIDTH # Screen width
SCREENHEIGHT # Screen height
TARGETLLEFTX # Target's lowerleft X
TARGETLLEFTY # Target's lowerleft Y
TARGETWIDTH # Width of the target
FORCEFACTOR # Arbitrary force factor
PROJECTILESPEED # Projectile's animation
speed
NORTH # Angle of north direction
SOUTH # Angle of south direction
EAST # Angle of east direction
WEST # Angle of west direction
# Setup the window.
turtle.setupSCREENWIDTH, SCREENHEIGHT
# Draw the target.
turtle.hideturtle
turtle.speed
turtle.penup
turtle.gotoTARGETLLEFTX TARGETLLEFTY
turtle.pendown
turtle.setheadingEAST
turtle.forwardTARGETWIDTH
turtle.setheadingNORTH
turtle.forwardTARGETWIDTH
turtle.setheadingWEST
turtle.forwardTARGETWIDTH
turtle.setheadingSOUTH
turtle.forwardTARGETWIDTH
turtle.penup
# Center the turtle.
turtle.goto
turtle.setheadingEAST
turtle.showturtle
turtle.speedPROJECTILESPEED
# Get the angle and force from the user.
angle floatinputEnter the projectile's angle:"
force floatinputEnter the launch force :
# Calculate the distance.
distance force FORCEFACTOR
# Set the heading.
turtle.setheadingangle
# Launch the projectile.
turtle.pendown
turtle.forwarddistance
# Did it hit the target?
if turtlexcor TARGETLLEFTX and
turtle.xcorTARGETLLEFTX TARGETWIDTH and
turtle.ycor TARGETLLEFTY and
turtle.ycorTARGETLLEFTY TARGETWIDTH:
printTarget hit!
else:
printYou missed the target.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
