-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalien_invasion.py
35 lines (29 loc) · 1.1 KB
/
alien_invasion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pygame
from pygame.sprite import Group
import game_functions as gf
from settings import Settings
from ship import Ship
from alien import Alien
def run_game():
# Initialize pygame, settings, and screen object
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
ai_settings.background_image = pygame.image.load('images/background_image.bmp').convert()
# Make a ship.
ship = Ship(ai_settings, screen)
aliens = Alien(ai_settings, screen)
bullets = Group()
aliens = Group()
gf.create_fleet(ai_settings, screen,ship, aliens)
# Start the main loop for the game.
while True:
# Watch for keyboard and mouse events.
gf.check_events(ai_settings, screen, ship, bullets)
ship.update()
bullets.update()
gf.update_bullets(aliens, bullets)
gf.update_aliens(ai_settings, aliens)
gf.update_screen(ai_settings, screen, ship, aliens, bullets)
run_game()