Gibt es eine Möglichkeit, die Schildkröte in Python Turtle Graphics langsamer zu bewegen?Python

Python-Programme
Anonymous
 Gibt es eine Möglichkeit, die Schildkröte in Python Turtle Graphics langsamer zu bewegen?

Post by Anonymous »

Ich habe ein Programm erstellt, um die Schildkrötenposition durch Drücken der Tastatur zu verschieben, aber gibt es eine Möglichkeit, sie in kleineren Pixelschritten zu verschieben?
Und ist das auch möglich? Schildkröte nach oben und unten bewegen statt nur nach links und rechts?

Code: Select all

from turtle import Screen, Turtle
TURTLE_SIZE = 200

# functions
def go_left():
t.direction = 'left'

def go_right():
t.direction = 'right'

screen = Screen()
screen.setup(1152,648)
screen.tracer(0)

# player
t = Turtle()
t.shape("circle")
t.speed("slowest")
t.color("blue")
t.penup()
t.setx(338)
t.sety(0)
t.direction = 'stop'

# Keyboard
screen.onkeypress(go_left, 'Left')
screen.onkeypress(go_right, 'Right')
screen.listen()

while True:
x = t.xcor()

if t.direction == 'left':
if x > TURTLE_SIZE - 576:
x -= 3
t.setx(x)
else:
t.direction = 'stop'
elif t.direction == 'right':
if x < 576 - TURTLE_SIZE:
x += 3
t.setx(x)
else:
t.direction = 'stop'

screen.update()

screen.mainloop()

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post
  • Setzt `Turtle.speed (0)` notwendig, wenn wir Turtle.tracer (0)
    by Anonymous » » in Python
    0 Replies
    1 Views
    Last post by Anonymous
  • Graphics.h in vscode
    by Anonymous » » in C++
    0 Replies
    1 Views
    Last post by Anonymous
  • Wie kann man die Größe einer Schildkröte ändern?
    by Anonymous » » in Python
    0 Replies
    2 Views
    Last post by Anonymous
  • Schildkröte nicht richtig initialisieren [doppelt]
    by Anonymous » » in Python
    0 Replies
    0 Views
    Last post by Anonymous
  • Wie entferne ich die Wiederholungsverzögerung in Python (mit Turtle) in Repl?
    by Anonymous » » in Python
    0 Replies
    3 Views
    Last post by Anonymous