-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBackground.py
More file actions
43 lines (33 loc) · 1.2 KB
/
Background.py
File metadata and controls
43 lines (33 loc) · 1.2 KB
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
#1/usr/bin/python2
########################################################################
# File Name: Background.py
# Authors: Nicole Lewey and Jacob Lundgren
# Date: 12/08/2014
# Class: CS360 - Open Source
# Assignment: Ninja Game - Create Open Source Project
# Purpose: Class for the background module
########################################################################
import pygame
class Background:
def __init__ (self, imageName = 'images/NinjaGame_Background.png'):
""" Constructor for the Background object
"""
try:
self._backgroundImage = pygame.image.load(imageName)
except pygame.error, message:
print 'Cannot load image:', imageName
raise SystemExit, message
self._backgroundImage.convert()
def setSurfaceToBackground(self, screen):
""" Draw the Background image onto the passed in Surface object
"""
screen.blit (self._backgroundImage, (0, 0))
def setBackgroundImage (self, imageName):
""" Sets the Background to the passed in image file name
"""
try:
self._backgroundImage = pygame.image.load(imageName)
except pygame.error, message:
print 'Cannot load image:', imageName
raise SystemExit, message
self._backgroundImage.convert()