diff --git a/circleshape.py b/circleshape.py index eb08882..5658953 100644 --- a/circleshape.py +++ b/circleshape.py @@ -13,6 +13,13 @@ class CircleShape(pygame.sprite.Sprite): self.velocity = pygame.Vector2(0, 0) self.radius = radius + def is_colided(self,other_circle): + distance = self.position.distance_to(other_circle.position) + if other_circle.radius + self.radius <= distance: + return True + else: + return False + def draw(self, screen): # sub-classes must override pass diff --git a/main.py b/main.py index f65a729..b6711f5 100644 --- a/main.py +++ b/main.py @@ -45,9 +45,12 @@ def main(): for drawable in drawables: drawable.draw(screen) - for updatable in updatables: updatable.update(dt) + for asteroid in asteroids: + if asteroid.is_colided(p1): + print("Game Over!") + return pygame.display.flip() tick = clock.tick(60)