15 lines
610 B
Python
15 lines
610 B
Python
import pygame
|
|
from game_object import GameObject
|
|
from snake_segment import SnakeSegment
|
|
|
|
|
|
class Snake(GameObject):
|
|
def __init__(self, start_position: tuple|list, length: int, radius: float|int, color: tuple) -> None:
|
|
self.__segments = [SnakeSegment(center=(start_position[0]+2*radius*idx, start_position[1]),
|
|
radius=radius,
|
|
color=color)
|
|
for idx in range(length)]
|
|
|
|
def draw(self, surface: pygame.Surface) -> None:
|
|
for segment in self.__segments:
|
|
segment.draw(surface) |