added load texturepack function, or at least started it!
This commit is contained in:
parent
3364106275
commit
0cd61dcb48
1 changed files with 16 additions and 9 deletions
25
textures.py
25
textures.py
|
@ -1,16 +1,23 @@
|
||||||
import os
|
import os, pygame, glob
|
||||||
class Textures():
|
class Textures():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.images = {
|
self.images = {
|
||||||
"PLAYER":"player.png",
|
"PLAYER":"player.png",
|
||||||
"BULLET":"bullet.png",
|
"BULLET":"bullet.png",
|
||||||
"TARGET":[]
|
"TARGETS":[]
|
||||||
}
|
}
|
||||||
self.path=os.path.dirname(os.path.realpath(__file__)) + "\\resources\\texture_packs"
|
self.path=os.path.dirname(os.path.realpath(__file__)) + "\\resources\\texture_packs\\"
|
||||||
self.pac
|
self.pack = "default"
|
||||||
def loadTexturePack(self, filename):
|
|
||||||
pass
|
def loadTexturePack(self, packName):
|
||||||
def getTexture(self, object):
|
if os.path.exists(self.path + packName):
|
||||||
directory =
|
targets = glob.glob(self.path+packName+"\\target*.png")
|
||||||
|
for file in files:
|
||||||
|
fileName = file.split("\\")[-1]
|
||||||
|
if
|
||||||
|
self.pack = packName
|
||||||
|
|
||||||
|
def getTexture(self, objectName):
|
||||||
|
filename = self.path + self.pack + "\\{0}.png".format(self.images[objectName.upper()])
|
||||||
|
return pygame.image.load(filename)
|
||||||
|
|
||||||
tex = Textures()
|
|
||||||
|
|
Reference in a new issue