Adding new code and ship image
This commit is contained in:
@ -2,14 +2,17 @@ import sys
|
||||
|
||||
import pygame
|
||||
|
||||
from settings import Settings
|
||||
|
||||
class AlienInvasion:
|
||||
"""Overall class to manage game assets and behaviour."""
|
||||
|
||||
def __init__(self):
|
||||
"""Intialize the game, and create game resources"""
|
||||
pygame.init()
|
||||
self.settings = Settings()
|
||||
|
||||
self.screen = pygame.display.set_mode((1200, 800))
|
||||
self.screen = pygame.display.set_mode((self.settings.screen_witdh, self.settings.screen_heigh))
|
||||
pygame.display.set.caption("Alien Invasion")
|
||||
|
||||
# Set the background color.
|
||||
@ -24,7 +27,7 @@ class AlienInvasion:
|
||||
sys.exit()
|
||||
|
||||
# Redraw the screen during each pass through the loop.
|
||||
self.screen.fill(self.bg_color)
|
||||
self.screen.fill(self.settings.bg_color)
|
||||
|
||||
# Make the most recently drawn screen visible.
|
||||
pygame.display.flip()
|
||||
|
||||
BIN
images/ship.bmp
Normal file
BIN
images/ship.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
@ -1,2 +1,9 @@
|
||||
class Settings:
|
||||
"""A class to store all settings for alien invasion."""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize the game's settings."""
|
||||
# Screen settings
|
||||
self.screen_witdh = 1200
|
||||
self.screen_heigh = 800
|
||||
self.bg_color =(230, 230, 230)
|
||||
Reference in New Issue
Block a user