From 0cd61dcb482e3241a5991ff1f09fc6e527836852 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 16 Apr 2015 13:23:15 +0100 Subject: [PATCH] added load texturepack function, or at least started it! --- textures.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/textures.py b/textures.py index 30f875e..6332765 100644 --- a/textures.py +++ b/textures.py @@ -1,16 +1,23 @@ -import os +import os, pygame, glob class Textures(): def __init__(self): self.images = { "PLAYER":"player.png", "BULLET":"bullet.png", - "TARGET":[] + "TARGETS":[] } - self.path=os.path.dirname(os.path.realpath(__file__)) + "\\resources\\texture_packs" - self.pac - def loadTexturePack(self, filename): - pass - def getTexture(self, object): - directory = + self.path=os.path.dirname(os.path.realpath(__file__)) + "\\resources\\texture_packs\\" + self.pack = "default" + + def loadTexturePack(self, packName): + if os.path.exists(self.path + packName): + 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()