-
Notifications
You must be signed in to change notification settings - Fork 0
/
alien_invasion.py
51 lines (31 loc) · 1.02 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import pygame
from pygame.sprite import Group
from settings import Settings
from ship import Ship
from alien import Alien
import game_functions as gf
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")
#makes a ship
ship = Ship(ai_settings,screen)
#Make an alien
alien = Alien(ai_settings,screen)
#Make a group to store bullets and a group for aliens
bullets = Group()
aliens = Group()
#Create the fleetof aliens
gf.create_fleet(ai_settings,screen,aliens)
#Make a group to store bullets in
bullets = Group()
#start the main loop for the game
while True:
gf.check_events(ai_settings,screen,ship,bullets)
ship.update()
bullets.update()
gf.update_bullets(bullets)
gf.update_screen(ai_settings,screen,ship,aliens,bullets)
run_game()