Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Change the following code so thatinstead of having a square for the aiand players boxers animation have itbe an actual character that is a boxerThe
Change the following code so thatinstead of having a square for the aiand players boxers animation have itbe an actual character that is a boxerThe code is in python: import turtleimport random# Set up the screenscreen turtle.ScreenscreentitleBoxing Game"screenbgcolorwhite# Playerplayer turtle.Turtleplayerspeedplayershapesquareplayercolorblueplayershapesizestretchwid stretchlenplayerpenupplayergoto# AIai turtle.Turtleaispeedaishapesquareaicolorredaishapesizestretchwid stretchlenaipenupaigoto# Heartsplayerhearts aihearts # Function to update heartsdef updatehearts: turtle.clear turtle.hideturtle turtle.penup turtle.goto turtle.colorblack turtle.writefPlayer Hearts: playerhearts AI Hearts: aihearts align"center", fontCourier "normal"# Function to handle player's movedef playermove: move inputChoose your move dodge left, dodge right, block, punch: lower return move# Function to handle AI's movedef aimove: moves dodge left", "dodge right", "block", "punch" return random.choicemoves# Function to handle punch animationdef punchanimationturtleobj, direction: turtleobj.shapecircle turtleobj.colorblack turtleobj.shapesizestretchwid stretchlen turtleobj.setheadingdirection turtleobj.stamp turtleobj.colorblue if turtleobj player else "red" # Explicitly set color turtleobj.shapesizestretchwid stretchlen# Main game loopwhile playerhearts and aihearts : playerchoice playermove aichoice aimove if playerchoice aichoice: printIts a draw!" elif playerchoice "dodge left" and aichoice "punch" or playerchoice "dodge right" and aichoice "punch": printYou dodged the punch! Free counter punch!" punchanimationai aihearts elif aichoice "dodge left" and playerchoice "punch" or aichoice "dodge right" and playerchoice "punch": printAI dodged the punch! AI gets a free counter punch!" punchanimationplayer playerhearts elif playerchoice "punch" and aichoice "block" or aichoice "punch" and playerchoice "block" : printPunch blocked!" elif playerchoice "punch": punchanimationplayer aihearts elif aichoice "punch": punchanimationai playerhearts updatehearts# Display the winnerturtle.clearturtlehideturtleturtlepenupturtlegototurtlecolorblackturtlewrite fYou win! if playerhearts else AI wins! align"center", fontCourier "normal"turtledone
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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