36 lines
951 B
Python
36 lines
951 B
Python
import pygame
|
|
from constants import *
|
|
from player import Player
|
|
|
|
def main():
|
|
print("Starting asteroids!")
|
|
print(f"Screen width: {SCREEN_WIDTH}")
|
|
print(f"Screen height: {SCREEN_HEIGHT}")
|
|
pygame.init()
|
|
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
|
|
clock = pygame.time.Clock()
|
|
dt = 0
|
|
|
|
drawables = pygame.sprite.Group()
|
|
updatables = pygame.sprite.Group()
|
|
|
|
Player.containers = (drawables, updatables)
|
|
p1 = Player(SCREEN_WIDTH/2,SCREEN_HEIGHT/2)
|
|
|
|
while True:
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
return
|
|
screen.fill((0, 0, 0))
|
|
|
|
for drawable in drawables:
|
|
drawable.draw(screen)
|
|
|
|
for updatable in updatables:
|
|
updatable.update(dt)
|
|
|
|
pygame.display.flip()
|
|
tick = clock.tick(60)
|
|
dt = tick/1000
|
|
if __name__ == "__main__":
|
|
main()
|