added astroids and astroid field
This commit is contained in:
parent
9365e50c64
commit
f0d7ef7cce
4 changed files with 89 additions and 0 deletions
20
main.py
20
main.py
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue