-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththeme.py
More file actions
46 lines (40 loc) · 1.85 KB
/
theme.py
File metadata and controls
46 lines (40 loc) · 1.85 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
44
45
46
import pygame
x = 1
y = 1
width = 30
height = 30
class Theme:
"""This class just holds theme information to be accessed later. Should be used to have changeable themes."""
backwardImg = pygame.image.load('assets/backwards.png')
def __init__(self,themeNum):
#Choosing animation frames based on theme number.
if themeNum == 0:
# theme 1 animations
boatSprites = self.initilazeFrames("theme1","boat",frameAmount=5)
islandSprites = self.initilazeFrames("theme1","island",frameAmount=3)
seaSprites = self.initilazeFrames("theme1","sea",frameAmount=3)
rocksSprites = self.initilazeFrames("theme1","rocks",frameAmount=1)
seaMineSprites = self.initilazeFrames("theme1","seaMine",frameAmount=1)
self.themeArrs = [boatSprites,islandSprites,seaSprites,rocksSprites,seaMineSprites]
self.background = pygame.image.load('assets/background5.png')
self.Color = (255,255,255)
elif themeNum == 1:
self.themeArrs = None
self.background = pygame.image.load('assets/background2.png')
self.Color = (30,30,160)
elif themeNum == 2:
self.themeArrs = None
self.background = pygame.image.load('assets/background3.png')
self.Color = (180,188,188)
else:
self.themeArrs = None
self.background = pygame.image.load('assets/background3.png')
self.Color = (180,188,188)
def initilazeFrames(self,themeName,fileName,frameAmount):
sprites = []
for i in range(frameAmount):
image = pygame.image.load('assets/{}/{}/{}.png'.format(themeName, fileName, i+1))
image.set_colorkey((255,255,255))
sprite_img = image.subsurface(x,y,width,height)
sprites.append(sprite_img)
return sprites