added astroids and astroid field

This commit is contained in:
specCon18 2025-01-16 11:37:57 -05:00
parent 9365e50c64
commit f0d7ef7cce
4 changed files with 89 additions and 0 deletions

20
main.py
View file

@ -1,26 +1,46 @@
import pygame
from constants import *
from player import Player
from asteroidfield import AsteroidField
from asteroid import Asteroid
def main():
# Print basic starting info
print("Starting asteroids!")
print(f"Screen width: {SCREEN_WIDTH}")
print(f"Screen height: {SCREEN_HEIGHT}")
# Initialize game, screen, game-clock and delta time counter
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
clock = pygame.time.Clock()
dt = 0
# Groups
drawables = pygame.sprite.Group()
updatables = pygame.sprite.Group()
asteroids = pygame.sprite.Group()
# Set the containers of the astroids
Asteroid.containers = (asteroids,drawables,updatables)
# Set the containers of the astroid_field
AsteroidField.containers = (updatables)
af = AsteroidField()
# Set the containers of player
Player.containers = (drawables, updatables)
# Set the position of the player
p1 = Player(SCREEN_WIDTH/2,SCREEN_HEIGHT/2)
while True:
# if event is quit then kill the game
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
# fill the screen with the void of space
screen.fill((0, 0, 0))
for drawable in drawables: