-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircleshape.py
More file actions
30 lines (24 loc) · 826 Bytes
/
circleshape.py
File metadata and controls
30 lines (24 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 colliding_with(self, other):
r1r2 = self.radius + other.radius
if (self.position.distance_to(other.position) <= r1r2):
return True
else:
return False
def draw(self, screen):
# sub-classes must override
pygame.draw.polygon(screen, "white", self.triangle(), 2)
def update(self, dt):
# sub-classes must override
pass