1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
attack-on-blocks/assets.py

36 lines
982 B
Python
Raw Normal View History

2015-04-18 16:32:14 +01:00
import os, pygame, glob, logging
from collections import namedtuple
2015-04-18 16:32:14 +01:00
2015-04-16 10:00:39 +01:00
class Textures():
def __init__(self):
self.images = {
"PLAYER":"player.png",
"BULLET":"bullet.png",
"TARGETS":[]
2015-04-16 10:00:39 +01:00
}
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):
2015-04-18 16:33:22 +01:00
self.images["TARGETS"] = []
targets = glob.glob(self.path+packName+"\\target*.png")
2015-04-18 16:33:22 +01:00
logging.debug("Found {0} target files.".format(len(targets)))
for file in targets:
fileName = file.split("\\")[-1]
2015-04-18 16:33:22 +01:00
self.images["TARGETS"].append(filename)
self.pack = packName
def getTexture(self, objectName):
filename = self.path + self.pack + "\\{0}.png".format(self.images[objectName.upper()])
return pygame.image.load(filename)
Level_Template = namedtuple('Level_Template', (rows, padding, firebacks))
Levels = [
Level_Template(2, 30, 0),
Level_Template(3, 15, 0)
]