[Python] Snake Game Creating a multiple Squares as a body of snake

Discussão em 'Python' iniciado por Stack, Abril 27, 2025.

  1. Stack

    Stack Membro Participativo

    from turtle import Screen,Turtle

    screen = Screen()
    screen.setup(600,600)
    screen.bgcolor("black")
    screen.title("New Snake Game ")

    turtle = Turtle(shape="square")
    turtle.color("white")
    # print(turtle)
    x = 10
    starting_position = []

    for i in range(0,3):
    starting_position.append(turtle)
    turtle.penup()
    turtle.goto(x=x,y=0)
    x += 20
    print(starting_position)



    screen.exitonclick()




    I am creating a python Snake Game.while using for loop I came across this issue, I want three squares to be created but squares are moving by 3 position. I dont know what I am missing.

    Continue reading...

Compartilhe esta Página