Im trying to create a game using pygame and when I run the code I get no errors but the pygame window wont open.
import sys
import pygame
from settings import Settings
class AlienInvasion:
"""Overall class to manage assets and behavior"""
def __init__(self):
"""initialize the game, create game resources"""
pygame.init()
self.screen = pygame.display.set_mode((1200, 800)) #Creates a display window
pygame.display.set_caption("Alien Invasion")
#set the background colour
def run_game(self):
"""start the main loop for the game"""
while True:
#Watch for keyboard and mouse events
for event in pygame.event.get(): # event is an action made by user
if event.type == pygame.QUIT:
sys.exit()
#Make the most recently drawn screen visible
pygame.display.flip()
if __name__ == '__main___':
#make a game instance, and run the game.
ai = AlienInvasion()
ai.run_game()
When I run the code I get:
pygame 2.1.2 (SDL 2.0.18, Python 3.10.4)
Hello from the pygame community. Contribute - pygame wiki
[Finished in 134ms]
The pygame window doesnt open at all