class Snake(pygame.sprite.Sprite):
image: Union[SurfaceType, Any]
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.Surface((12,12))
self.image.dill(WHITE)
self.rect=self.image.get_rect()
self.rect.center=(100,100)
self.speedx=0
self.speedy=0
self.score=0
self.tail=[]
class Food(pygame.sprite.Sprite):
def __init__(self,x,y):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.Surface((12,12))
self.image.fill(RED)
self.rect=self.image.get_rect()
self.rect.center=(x,y)
all_sprites=pygame.sprite.Group()
player=Snake()
food=Food(random.randrange(20,width-20),random.randrange(20,height-20))
all_sprites.add(player)
all_sprites.add(food)
Ошибки:
Traceback (most recent call last):
File "C:/Users/Asus/Documents/snake.py", line 100, in <module>
player=Snake()
File "C:/Users/Asus/Documents/snake.py", line 48, in __init__
self.image.dill(WHITE)
AttributeError: 'pygame.Surface' object has no attribute 'dill'