-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path\
More file actions
40 lines (36 loc) · 1.17 KB
/
Copy path\
File metadata and controls
40 lines (36 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# this allows us to use code from
# the open-source pygame library
# throughout this file
import pygame
from constants import *
from circleshape import *
from player import *
from asteroid import *
from asteroidfield import *
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
def main():
print("Starting Asteroids!")
print (f"Screen width: {SCREEN_WIDTH}")
print(f"Screen height: {SCREEN_HEIGHT}")
updatable = pygame.sprite.Group()
drawable = pygame.sprite.Group()
asteroids = pygame.sprite.Group()
AsteroidField.containers = (updatable)
Asteroid.containers = (updatable, drawable, asteroids)
Player.containers = (updatable, drawable)
clock = pygame.time.Clock()
player = Player(SCREEN_WIDTH/2, SCREEN_HEIGHT/2)
asteroid_field = AsteroidField()
dt =0
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
pygame.Surface.fill(screen, "black")
updatable.update(dt)
for drawables in drawable:
drawables.draw(screen)
pygame.display.flip()
dt = clock.tick(60)/1000
if __name__ == "__main__":
main()