As exactly the same issue described here, expecting to see 3 white boxes move across the screen. I tried two variants of the code (including the one posted as the solution above) but got a black screen and this in the terminal.
With error:
Traceback (most recent call last):File "c:\Users\gil47982\Documents\PythonDocs\snake\main.py", line 63, in segment.forward(20)File "C:\Program Files\Python310\lib\turtle.py", line 1637, in forwardself._go(distance)File "C:\Program Files\Python310\lib\turtle.py", line 1605, in _goself._goto(ende)File "C:\Program Files\Python310\lib\turtle.py", line 3159, in _gotoscreen._pointlist(self.currentLineItem),File "C:\Program Files\Python310\lib\turtle.py", line 753, in pointlistcl = self.cv.coords(item)File "", line 1, in coordsFile "C:\Program Files\Python310\lib\tkinter_init.py", line 2795, in coordsself.tk.call((self._w, 'coords') + args))]_tkinter.TclError: invalid command name ".!canvas"
I tried the answer to the original code, as well as my own code and got the error posted above. This is the code I'm expecting to see drawing 3 boxes moving.
My own solution code:
from turtle import Turtle, Screen
window = Screen()
window.setup(width=600, height=600)
window.bgcolor("black")
window.title("Lucas' Snake Game")
window.tracer(0)
squares = []
xoffset = 0
for _ in range(0,3):
new_square = Turtle("square")
new_square.pu()
new_square.color("light green")
new_square.setpos(xoffset,0)
squares.append(new_square)
xoffset -= 20
game_is_on = True
while game_is_on:
for square in squares:
square.fd(50)
window.update()
window.exitonclick()
Which seems to show just a black screen (presumably, the boxes have moved off?) and the same error code as above. I'm following this through on a Udemy tutorial, and the same code (minor variance in variable names) has the 3 boxes wriggling across the screen.
Any help is much appreciated!