[Python] How to move a turtle stamp in python

Discussão em 'Python' iniciado por Stack, Fevereiro 7, 2025.

  1. Stack

    Stack Membro Participativo

    How do I move a stamp in python turtle module?

    Here's my code so far:

    import turtle

    def draw_start():
    turtle.pu()
    turtle.setpos(-350,300)
    turtle.pendown()
    turtle.right(90)
    turtle.forward(520)


    def draw_finish():
    turtle.speed(15)
    turtle.pu()
    for i in range(18):
    turtle.setpos(200,(300-(i*30)))
    square()
    for j in range(18):
    turtle.setpos(215,(285-(j*30)))
    square()

    def stamp_turtle(x,y,color):
    turtle.pu()
    turtle.setheading(0)
    turtle.shape("turtle")
    turtle.color(color)
    turtle.setpos(x,y)
    stamp_list.append(turtle.stamp())

    def square():
    turtle.pu()
    turtle.fill(True)
    for i in range(4):
    turtle.forward(15)
    turtle.right(90)
    turtle.fill(False)

    print "Welcome to Turtle Racing : "
    number_of_turtles = int(raw_input("How many turtles (between 3 and 6) : "))
    bet_amount = int(raw_input("How much do you want to bet? $ "))
    bet_turtle = raw_input("Which turtle (1 to 5)? ")

    color_list=["red","blue","green","brown","yellow","purple"]
    stamp_list=[]
    draw_start()
    draw_finish()
    for i in range(number_of_turtles):
    stamp_turtle(-370,280-i*90,color_list)`

    Continue reading...

Compartilhe esta Página