Adding in pygame, and getting a window to display/close

This commit is contained in:
franky212
2024-10-28 15:06:43 -06:00
parent cd6cffd9df
commit 90d55e89b7
4 changed files with 32 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
venv/
__pycache__/

7
constants.py Normal file
View File

@@ -0,0 +1,7 @@
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720
ASTEROID_MIN_RADIUS = 20
ASTEROID_KINDS = 3
ASTEROID_SPAWN_RATE = 0.8 # seconds
ASTEROID_MAX_RADIUS = ASTEROID_MIN_RADIUS * ASTEROID_KINDS

22
main.py Normal file
View File

@@ -0,0 +1,22 @@
# this allows us to use code from
# the open-source pygame library
# throughout this file
import pygame
from constants import *
def main():
pygame.init()
print("Starting asteroids!")
print(f"Screen width: {SCREEN_WIDTH}")
print(f"Screen height: {SCREEN_HEIGHT}")
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
pygame.Surface.fill(screen, (0, 0, 0))
pygame.display.flip()
if __name__ == "__main__":
main()

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
pygame==2.6.0