[Python] Turtles moving on a board game

Discussão em 'Python' iniciado por Stack, Setembro 14, 2025.

  1. Stack

    Stack Membro Participativo

    I am currently creating Candyland in Python and I'm using turtles for the board. After the first turn the turtles are in a stopped position but on the second turn I created a ton of if statements for the turtles positions such as

    if P1.pos() == y10:
    if draw2 == "Red":
    P1.goto(r11)
    if draw2 == "Red Red":
    P1.goto(r12)
    if draw2 == "Purple":
    P1.goto(p11)
    if draw2 == "Purple Purple":
    P1.goto(p12)
    if draw2 == "Yellow":
    P1.goto(y11)
    if draw2 == "Yellow Yellow":
    P1.goto(y12)
    if draw2 == "Blue":
    P1.goto(b10)
    if draw2 == "Blue Blue":
    P1.goto(b11)
    if draw2 == "Orange":
    P1.goto(o10)
    if draw2 == "Orange Orange":
    P1.goto(o11)
    if draw2 == "Green":
    P1.goto(g10)
    if draw2 == "Green Green":
    P1.goto(g11)


    my issue is that the turtles now will go all the way to the end because there is an if statement like the one above for every space on the board. How do i make the turtles stop after one movement so that they don't end the game on the second turn.

    Continue reading...

Compartilhe esta Página