asteroids/main.py

28 lines
701 B
Python
Raw Normal View History

2024-10-08 12:38:46 +00:00
import pygame
2024-10-08 17:00:59 +00:00
from player import Player
2024-10-08 12:38:46 +00:00
from constants import *
2024-10-08 17:00:59 +00:00
2024-10-08 12:38:46 +00:00
def main():
2024-10-08 17:00:59 +00:00
print("Starting asteroids!")
2024-10-08 12:38:46 +00:00
print(f"Screen width: {SCREEN_WIDTH}")
print(f"Screen height: {SCREEN_HEIGHT}")
pygame.init()
2024-10-08 17:00:59 +00:00
clock = pygame.time.Clock()
dt = 0
2024-10-08 12:38:46 +00:00
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
2024-10-08 17:00:59 +00:00
player = Player(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
2024-10-08 12:38:46 +00:00
while True:
2024-10-08 13:08:41 +00:00
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
2024-10-08 17:00:59 +00:00
pygame.Surface.fill(screen, (0, 0, 0))
player.draw(screen)
2024-10-08 12:38:46 +00:00
pygame.display.flip()
2024-10-08 17:00:59 +00:00
t = clock.tick(60)
dt = t / 1000
2024-10-08 12:38:46 +00:00
if __name__ == "__main__":
main()