added main game loop
This commit is contained in:
commit
bfd9971cfb
4 changed files with 27 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
venv/
|
||||||
|
__pycache__/
|
||||||
7
constants.py
Normal file
7
constants.py
Normal 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
|
||||||
17
main.py
Normal file
17
main.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import pygame
|
||||||
|
from constants import *
|
||||||
|
|
||||||
|
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))
|
||||||
|
while True:
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
return
|
||||||
|
screen.fill((0, 0, 0)) # simplified fill call
|
||||||
|
pygame.display.flip() # fixed typo in flip
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
pygame==2.6.1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue