29 lines
752 B
Python
29 lines
752 B
Python
from typing import Self
|
|
|
|
import pygame
|
|
|
|
|
|
class CircleShape(pygame.sprite.Sprite):
|
|
containers: tuple[pygame.sprite.Group, ...]
|
|
|
|
def __init__(self, x: float, y: float, radius: float) -> None:
|
|
if hasattr(self, "containers"):
|
|
super().__init__(*self.containers)
|
|
else:
|
|
super().__init__()
|
|
|
|
self.position: pygame.Vector2 = pygame.Vector2(x, y)
|
|
self.velocity = pygame.Vector2(0, 0)
|
|
self.radius = radius
|
|
|
|
def draw(self, screen: pygame.Surface) -> None:
|
|
pass
|
|
|
|
def update(self, dt: float) -> None:
|
|
pass
|
|
|
|
def collides_with(self, other: Self) -> bool:
|
|
d = self.position.distance_to(other.position)
|
|
r = self.radius + other.radius
|
|
return d < r
|