diff --git a/alien_invasion.py b/alien_invasion.py new file mode 100644 index 0000000..159b37b --- /dev/null +++ b/alien_invasion.py @@ -0,0 +1,36 @@ +import sys + +import pygame + +class AlienInvasion: + """Overall class to manage game assets and behaviour.""" + + def __init__(self): + """Intialize the game, and create game resources""" + pygame.init() + + self.screen = pygame.display.set_mode((1200, 800)) + pygame.display.set.caption("Alien Invasion") + + # Set the background color. + self.bg_color = (230, 230, 230) + + def run_game(self): + """Start main loop for the game.""" + while True: + # Watch for keyboard and mouse events. + for event in pygame.event.get(): + if event.type == pygame.QUIT: + sys.exit() + + # Redraw the screen during each pass through the loop. + self.screen.fill(self.bg_color) + + # Make the most recently drawn screen visible. + pygame.display.flip() + +if __name__ == '__main__': + # Make a game instance, and run the game.get() + ai = AlienInvasion() + ai.run.game() + diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..02389e6 --- /dev/null +++ b/settings.py @@ -0,0 +1,2 @@ +class Settings: + """A class to store all settings for alien invasion."""