Files

29 lines
752 B
Python
Raw Permalink Normal View History

2026-05-22 09:34:56 -05:00
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