Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help!! 1) Allow for six arrows to be shot rather than three.-- You need to use a list to hold six arrows so you

Need help!!

1) Allow for six arrows to be shot rather than three.-- You need to use a list to hold six arrows so you are able to use a for loop to animate arrow shooting repeatedly, while removing arrow2 and arrow3.# make 6 arrowsarrow = list()for i in range(6): arrow.append(arrow1.clone())

2) Produce a smoother animation of the arrow movement. -- Define a variable to specify smooth degree, smoothDegree. In the original source code, an arrow moves 37-41 pixels horizontally as one step. It can be changed to a smaller number of pixels for one step of movements. The higher of the smooth degree (for example, 1-10) is, the smoother the animation will be. You then need to use a while loop to give the rest points for the trajectory of arrow movements.

3) All arrows start at the same location (e.g., (15, 120)), but the final location (or the end point) of each arrow is with its tip precisely at the point on which the user clicked inside the target. Youll need to use the code segment provided below to get the end point.

cue = target.wait()targ = cue.getMouseLocation() targetX = targ.getX()+160 targetY = targ.getY()+110

Notice that the location returned from cue.getMouseLocation()is relative to the center of target at (160, 110). So it needs to be adjusted to refer to the Canvas and keep consistent with the start point.

While you work on 2) smoothing, maintain the current position of the moving arrow, arrow[i], at (currentX, currentY). Use stepX and stepY for move increments toward (targetX, targetY). They can be calculated as follows:

stepX = (targetX - startX)/(2*smoothDegree) stepY = (targetY startY)/(2*smoothDegree)

In case that stepX and stepY are not added up exactly to targetX and targetY, you may add last move as follows right after the while loop so that the arrow will stop precisely at (targetX, targetY).

arrow[i].moveTo(targetX, targetY)

Rotate an arrow properly so it looks better in moving.

Your program should include the following functions.---- arrowMovement(arrow, startX, startY, endX, endY, smoothDegree) to allow an arrow to move from (startX, startY) to (endX, endY) in smoothDegree.

---- yesOrNo(prompt) to ask the user a question with the given prompt and demand a response of yes or no so the program may start over again

need help with the answers plz include detailed steps as comments

what I have done so far

from cs1graphics import * from time import sleep

scene = Canvas() scene.setBackgroundColor('skyBlue') grass = Rectangle(200, 80, Point(100,160)) grass.setFillColor('green') grass.setBorderColor('green') grass.setDepth(100) scene.add(grass) sun = Circle(20, Point(50,30)) sun.setFillColor('yellow') scene.add(sun)

target = Layer() outside = Circle(30) outside.setFillColor('white') outside.setDepth(49) target.add(outside) middle = Circle(20) middle.setFillColor('blue') middle.setDepth(48) target.add(middle) inside = Circle(10) inside.setFillColor('red') inside.setDepth(47) target.add(inside) legs = Path(Point(-25,45), Point(0,0), Point(25,45)) legs.setBorderWidth(2) target.add(legs) target.move(160,110) target.setDepth(75) # in front of grass; behind arrows scene.add(target)

# prepare three arrows, but do not yet add to scene arrow1 = Layer() tip = Polygon(Point(0,0), Point(-8,5), Point(-5,0), Point(-8,-5)) tip.setFillColor('white') arrow1.add(tip) shaft = Path(Point(-30,0), Point(-5,0)) shaft.setBorderWidth(2) shaft.setDepth(51) arrow1.add(shaft) fletching = Polygon(Point(-30,0), Point(-33,-3), Point(-40,-3), Point(-36,0), Point(-38,3), Point(-36,3)) fletching.setFillColor('white') arrow1.add(fletching) arrow1.move(15,120) # initial position arrow2 = arrow1.clone() arrow3 = arrow1.clone()

dialogue = Text('Click target to fire an arrow') dialogue.move(100,170) scene.add(dialogue)

target.wait() # wait indefinitely for user event on target scene.add(arrow1) arrow1.rotate(-20) sleep(0.25) arrow1.move(41,-15) arrow1.rotate(7) sleep(0.25) arrow1.move(41,-5) arrow1.rotate(7) sleep(0.25) arrow1.move(41,5) arrow1.rotate(7) sleep(0.25) arrow1.move(41,17) arrow1.rotate(7)

target.wait() # wait indefinitely for user event on target scene.add(arrow2) arrow2.rotate(-40) sleep(0.25) arrow2.move(39,-22) arrow2.rotate(17) sleep(0.25) arrow2.move(39,-12) arrow2.rotate(17) sleep(0.25) arrow2.move(39,3) arrow2.rotate(17) sleep(0.25) arrow2.move(39,13) arrow2.rotate(17)

target.wait() # wait indefinitely for user event on target scene.add(arrow3) arrow3.rotate(-30) sleep(0.25) arrow3.move(37,-26) arrow3.rotate(10) sleep(0.25) arrow3.move(37,-11) arrow3.rotate(10) sleep(0.25) arrow3.move(37,6) arrow3.rotate(10) sleep(0.25) arrow3.move(37,21) arrow3.rotate(10) dialogue.setMessage('Good shooting!')

scene.wait() # wait for user event anywhere on canvas scene.close()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

What is home equity? Describe how a home equity loan works.

Answered: 1 week ago

Question

Carry out an interview and review its success.

Answered: 1 week ago