the game is gamin

This commit is contained in:
Itsig0
2025-03-10 13:00:07 +01:00
parent 1e38fb37d1
commit 275022f295
7 changed files with 226 additions and 0 deletions

31
asteroid.py Normal file
View File

@@ -0,0 +1,31 @@
import random
import pygame
from circleshape import CircleShape
from constants import ASTEROID_MIN_RADIUS
class Asteroid(CircleShape):
def __init__(self, x, y, radius):
super().__init__(x, y, radius)
def draw(self, screen):
pygame.draw.circle(screen, "white", self.position, self.radius, 2)
def update(self, dt):
self.position += self.velocity * dt
def split(self):
self.kill()
if self.radius <= ASTEROID_MIN_RADIUS:
return
new_angle = random.uniform(20,50)
new_velocity_1 = self.velocity.rotate(new_angle)
new_velocity_2 = self.velocity.rotate(-new_angle)
new_radius = self.radius - ASTEROID_MIN_RADIUS
new_asteroid_1 = Asteroid(self.position[0], self.position[1], new_radius)
new_asteroid_2 = Asteroid(self.position[0], self.position[1], new_radius)
new_asteroid_1.velocity = new_velocity_1 * 1.2
new_asteroid_2.velocity = new_velocity_2 * 1.2