так что я создаю игру в змею, используя модуль черепахи Python.в настоящее время я рисую голову змеи, используя этот код:
# Snake head
head = turtle.Turtle() # create an instance of the class turtle called 'head'
head.speed(0) # call the speed method
head.shape("square") # defines the shape of the snakes head
head.color("black") # defines the colour of the snakes head
head.penup() # stop the snake from drawing when moving
head.goto(0,0) # moves the snakes head to the coordinates 0,0 on the screen.
head.direction = "stop" # stops the turtles head from moving strait away
Вместо рисования я хотел бы импортировать изображение и использовать его в качестве головы змеи.здесь приведен код
image1 = "D:\Desktop\computing\Python\snake game\img\snake_head.png"
head = turtle.Turtle()
head.speed(0)
head.addshape(image1)
head.goto(0,0)
head.direction = "stop"
после некоторого исследования, которое я обнаружил здесь , вы можете использовать метод, называемый "addhape", для импорта изображения.Однако, когда я запускаю код, я получаю сообщение об ошибке:
AttributeError: 'Turtle' object has no attribute 'addshape'