如何使用箭头键向下移动乌龟?

时间:2019-10-15 00:00:34

标签: python pycharm turtle-graphics arrow-keys

试图弄清楚如何将乌龟向下而不是左右移动,这是下面的代码和链接:

class Player(turtle.Turtle):  # since it got inherited this class becomes a Superclass/SUPER CLASS
    def __init__(self):  # self is our only argument here but it will have multiple attributes
        turtle.Turtle.__init__(self)  # since we are using the Turtle module, we are able to use it's built in functions
        self.penup()# our attributes
        self.speed(0)
        self.shape("C:/Users/Rafael Perez/PycharmProjects/hello/venv/r7.gif")
        self.color("black")
        self.velocity = 0.1

    def move(self):
        self.forward(self.velocity)

        # Border Checking
        if self.xcor() > 290 or self.xcor() < -290:  # Left side is -290 Right side is 290 we also want the coordinates x and y to be below 300 to not go over our border
            self.left(60)
        if self.ycor() > 290 or self.ycor() < -290:
            self.left(60)

    def turnleft(self):
        self.left(30)

    def turnright(self):
        self.right(30)

    def down(self):
        self.forward(30)

    def increasespeed(self):
        self.velocity += 1

Ralph94

0 个答案:

没有答案