I'd like to create a function to make it easier for me to load and scale images. I have a lot of images in one folder which I use the same path to get to, and they all have the same names as the PNG files. How would I create a function where I could imput a list of file names, and have Python create variables with said names, and then scale them accordingly?
Here is the code I have right now:
Ocean = p.image.load("textures/tiles/Ocean.png")
Grassland = p.image.load("textures/tiles/Grassland.png")
Plains = p.image.load("textures/tiles/Plains.png")
FGrassland = p.image.load("textures/tiles/FGrassland.png")
FPlains = p.image.load("textures/tiles/FPlains.png")
HGrassland = p.image.load("textures/tiles/HGrassland.png")
HPlains = p.image.load("textures/tiles/HPlains.png")
MGrassland = p.image.load("textures/tiles/MGrassland.png")
MPlains =p.image.load("textures/tiles/MPlains.png")
Desert = p.image.load("textures/tiles/Desert.png")
HDesert = p.image.load("textures/tiles/HDesert.png")
Tundra = p.image.load("textures/tiles/Tundra.png")
FTundra = p.image.load("textures/tiles/FTundra.png")
HTundra = p.image.load("textures/tiles/HTundra.png")
MTundra = p.image.load("textures/tiles/MTundra.png")
Undiscovered = p.image.load("Undiscovered.png")
#########################################
Ocean = p.transform.scale(Ocean,(EFFECTIVE_SCALE,EFFECTIVE_SCALE))
Grassland = p.transform.scale(Grassland, (EFFECTIVE_SCALE, EFFECTIVE_SCALE))
FGrassland = p.transform.scale(FGrassland, (EFFECTIVE_SCALE, EFFECTIVE_SCALE))
HGrassland = p.transform.scale(HGrassland, (EFFECTIVE_SCALE, EFFECTIVE_SCALE))
MGrassland = p.transform.scale(MGrassland, (EFFECTIVE_SCALE, EFFECTIVE_SCALE))
Plains = p.transform.scale(Plains, (EFFECTIVE_SCALE, EFFECTIVE_SCALE))
Desert = p.transform.scale(Desert, (EFFECTIVE_SCALE, EFFECTIVE_SCALE))
Tundra = p.transform.scale(Tundra, (EFFECTIVE_SCALE, EFFECTIVE_SCALE ))
FTundra = p.transform.scale(FTundra, (EFFECTIVE_SCALE, EFFECTIVE_SCALE ))
Undiscovered = p.transform.scale(Undiscovered, (EFFECTIVE_SCALE, EFFECTIVE_SCALE))
HTundra = p.transform.scale(HTundra, (EFFECTIVE_SCALE, EFFECTIVE_SCALE))
MTundra = p.transform.scale(MTundra, (EFFECTIVE_SCALE, EFFECTIVE_SCALE))
I'd like to create something like this:
def LoadTextures(self,textureList):
for t in range textureList:
texturepath = str("textures/tiles/" + textureList[t] + ".png")
(create a new variable with the name of the png) = p.image.load("texturepath")
(use same variable name as the above line) = p.transform.scale(textureList[t],(EFFECTIVE_SCALE,EFFECTIVE_SCALE))
Anyone have any ideas how I could do this?