Files
asteroids/circleshape.py
2024-10-28 17:31:31 -06:00

27 lines
730 B
Python

import pygame
# Base class for game objects
class CircleShape(pygame.sprite.Sprite):
def __init__(self, x, y, radius):
# we will be using this later
if hasattr(self, "containers"):
super().__init__(self.containers)
else:
super().__init__()
self.position = pygame.Vector2(x, y)
self.velocity = pygame.Vector2(0, 0)
self.radius = radius
def collision(self, other):
if self.position.distance_to(other.position) <= (self.radius + other.radius):
return True
return False
def draw(self, screen):
# sub-classes must override
pass
def update(self, dt):
# sub-classes must override
pass