-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpaceFight.py
42 lines (30 loc) · 1.12 KB
/
SpaceFight.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
import pygame
from pygame.sprite import Group
import game_functions as gf
from game_stats import GameStats
from settings import Settings
from ship import Ship
from button import Button
def run_game():
# Initialise the game and create a screen object
pygame.init()
sf_settings = Settings()
screen = pygame.display.set_mode((sf_settings.screen_width, sf_settings.screen_height))
pygame.display.set_caption('Space Fight')
play_button = Button(sf_settings, screen, 'play')
stats = GameStats(sf_settings)
#create a ship
ship = Ship(sf_settings, screen)
#create a Group for bullets
bullets = Group()
aliens = Group()
gf.create_fleet(sf_settings, screen, ship, aliens)
# Start the main loop of the game
while True:
gf.check_events(sf_settings, screen, ship, bullets)
if stats.game_active:
ship.update()
gf.update_bullets(sf_settings, screen, ship, aliens, bullets)
gf.update_aliens(sf_settings, stats, screen, ship, aliens, bullets)
gf.update_screen(sf_settings, screen, stats, ship, aliens, bullets, play_button)
run_game()