Question

import turtle player = {"name": "Player 1", "turtle" : turtle.Turtle(), "color":"blue", "radius": 10, "move_distance" : 5...

import turtle

player = {"name": "Player 1", "turtle" : turtle.Turtle(), "color":"blue", "radius": 10, "move_distance" : 5 }



#TODO: hide the player turtle

screen = player["turtle"].getscreen()


def up():

print("starting up")

t = player["turtle"] # for convenience

t.clear()

current_y = t.ycor()

# TODO: add the player's move distance to the current y

t.sety(new_y)

# TODO: use the player's radius

t.dot()

# TODO: create down, left and right functions


screen.onkey(up, "Up")

# TODO: hook up key event handlers so that arrow keys trigger appropriate function

# Can multiple keys trigger the same function? Give it a try

screen.listen()

Homework Answers

Answer #1

Ans:

'''

The required program in turtle python can be implemented in the following manner so as to satisfy the above mentioned TODO's:

'''

# PROGRAM :

import turtle

player = {"name": "Player 1", "turtle" : turtle.Turtle(), "color":"blue", "radius": 10, "move_distance" : 5 }


#TODO: hide the player turtle
player["turtle"].hideturtle() # to hide the turtle

screen = player["turtle"].getscreen()

def up():

print("starting up")

t = player["turtle"] # for convenience

t.clear()

current_y = t.ycor()

# TODO: add the player's move distance to the current y
new_y = current_y + player["move_distance"]
t.sety(new_y)

# TODO: use the player's radius

t.dot(player["radius"])

# TODO: create down, left and right functions

def down():

print("starting down")
  
def left():

print("starting left")
  
def right():

print("starting right")
  
screen.onkey(up, "Up")

# TODO: hook up key event handlers so that arrow keys trigger appropriate function

screen.onkey(down, "Down")

screen.onkey(left, "Left")

screen.onkey(right, "Right")

# Can multiple keys trigger the same function? Give it a try
'''
no! on trying multiple keys at the same time the same function doesn't
get invoked! Separate functions is needed to handle such an event

'''
screen.listen()

# OUTPUT OF A SAMPLE RUN:

# PLEASE DO LIKE AND UPVOTE IF THIS WAS HELPFUL!

# THANK YOU SO MUCH IN ADVANCE!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
convert to python 3 from python 2 from Tkinter import * # the blueprint for a...
convert to python 3 from python 2 from Tkinter import * # the blueprint for a room class Room(object): # the constructor def __init__(self,name,image): # rooms have a name, exits (e.g., south), exit locations (e.g., to the south is room n), # items (e.g., table), item descriptions (for each item), and grabbables (things that can # be taken and put into the inventory) self.name = name self.image = image self.exits = {} self.items = {} self.grabbables = [] # getters...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):         self.name = name         self.pop = pop         self.area = area         self.continent = continent     def getName(self):         return self.name     def getPopulation(self):         return self.pop     def getArea(self):         return self.area     def getContinent(self):         return self.continent     def setPopulation(self, pop):         self.pop = pop     def setArea(self, area):         self.area = area     def setContinent(self, continent):         self.continent = continent     def __repr__(self):         return (f'{self.name} (pop:{self.pop}, size: {self.area}) in {self.continent} ') TASK 2 Python Program: File: catalogue.py from Country...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...