Snake head now showing when trying to build the snake game using python module turtle

0 votes

I am trying to build the snake game using the python's turtle module. This is my code so far:

import turtle

#set up the screen
wn = turtle.Screen()
wn.title("snake game")
wn.bgcolor("Blue")
wn.setup(width=600, height=600)
wn.tracer(0)

#Snake Head
head = turtle.Turtle()
head.speed(0)
head.shape("square")
head.color("Black")
head.penup()
head.goto(0, 0)
head.direction = "stop"

turtle.mainloop()

I've created the snake head but when I test for it, it does not show. Is my logic wrong?

Jun 19 in Python by Nagya
148 views

1 answer to this question.

0 votes

Hey @Nagya, so you added the following line in your code:

wn.tracer(0)

It basically turns off the screen updates. Add the following lines:

# Main game loop
while True:
    wn.update()
answered Jun 19 by Faiza

Related Questions In Python

0 votes
1 answer

Change the snake head color using python turtle

You can et the snakehead color by ...READ MORE

answered Jun 19 in Python by Faiza
47 views
0 votes
1 answer

Draw a square using the turtle module - Python

Hey @Baily, use something like this: import turtle sq ...READ MORE

answered Jun 21 in Python by Himanshu
88 views
0 votes
1 answer

How do I create a star using the turtle module of python?

Hey @Jinu, Try something like this: import turtle star = ...READ MORE

answered Jun 21 in Python by Neha
75 views
0 votes
1 answer

How do I draw a hexagon using the turtle module of python?

Hey @Jinu, try this: import turtle polygon = ...READ MORE

answered Jun 23 in Python by Haseeb
412 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 423 views
+4 votes
6 answers
0 votes
1 answer

Snake head placed on the center - Python using turtle

You can use turtle's goto() function. This ...READ MORE

answered Jun 21 in Python by Greg
66 views
0 votes
1 answer

Move turtle using the arrow keys in Python

You can use something like this: wn.onkey(move_up, 'Up') wn.onkey(move_left, ...READ MORE

answered Jul 5 in Python by Travis
280 views