Change the window background color using turtle - python

0 votes

I'm trying to build the snake game using turtle (python module). I've created the window and the snakehead so far. The background color of the window is white. I want it to be blue. How do I change it? Thank you 

Code:

import turtle

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

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


# Main game loop
while True:
    wn.update()

turtle.mainloop()

Jun 19 in Python by Mihir
510 views

1 answer to this question.

0 votes

Try this:

import turtle

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

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


# Main game loop
while True:
    wn.update()

turtle.mainloop()

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
30 views
0 votes
0 answers

How change title bar background color in python tkinter?

Jun 1 in Python by anonymous

recategorized Jun 3 by Omkar 294 views
0 votes
1 answer
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
55 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 279 views
+4 votes
6 answers
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,720 points
1,911 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
72 views