Chargement des texture dans les sous dossiers #15
|
@ -4,7 +4,7 @@ Définis un plugin permettant d'afficher des choses a l'écran.
|
||||||
|
|
||||||
from engine import *
|
from engine import *
|
||||||
from engine.math import Vec2
|
from engine.math import Vec2
|
||||||
import pygame, os
|
import pygame, glob
|
||||||
|
|
||||||
from engine.plugins.pygame import Display
|
from engine.plugins.pygame import Display
|
||||||
|
|
||||||
|
@ -84,10 +84,12 @@ class TextureManager:
|
||||||
|
|
||||||
def __init__(self, display: Display) -> None:
|
def __init__(self, display: Display) -> None:
|
||||||
self._textures: dict[str, pygame.Surface] = {}
|
self._textures: dict[str, pygame.Surface] = {}
|
||||||
for file in os.listdir("textures"):
|
for file in glob.iglob("textures/**/*.png", recursive=True):
|
||||||
self._textures[file] = pygame.image.load(f"textures/{file}").convert(
|
self._textures[file] = pygame.image.load(file).convert_alpha(
|
||||||
display._surface
|
display._surface
|
||||||
)
|
)
|
||||||
|
for file in glob.iglob("textures/**/*.jpg", recursive=True):
|
||||||
|
self._textures[file] = pygame.image.load(file).convert(display._surface)
|
||||||
error_texture = pygame.Surface((256, 256))
|
error_texture = pygame.Surface((256, 256))
|
||||||
error_texture.fill((0, 0, 0))
|
error_texture.fill((0, 0, 0))
|
||||||
pygame.draw.rect(error_texture, (255, 0, 255), (0, 0, 128, 128))
|
pygame.draw.rect(error_texture, (255, 0, 255), (0, 0, 128, 128))
|
||||||
|
|
Loading…
Reference in a new issue