Merge branch 'main' into sound
This commit is contained in:
commit
492f3c180f
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"end_image": "0000.png",
|
||||
"end_image": "story/chapter1/background.png",
|
||||
"offset": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"frame_count": 268,
|
||||
"frame_count": 529,
|
||||
"fps": 60
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 681 KiB After Width: | Height: | Size: 682 KiB |
BIN
assets/textures/story/chapter1/background.png
Normal file
BIN
assets/textures/story/chapter1/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 110 KiB |
|
@ -3,7 +3,6 @@ Un moteur de jeu inspiré de bevy.
|
|||
"""
|
||||
|
||||
|
||||
import glob
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
|
@ -281,14 +280,8 @@ class Assets:
|
|||
pygame.draw.rect(error_texture, (255, 0, 255), (128, 128, 128, 128))
|
||||
self.__error_texture = error_texture.convert(surface)
|
||||
|
||||
# Chargement des textures
|
||||
# Cache des ressources
|
||||
self.__textures: dict[str, pygame.Surface] = {}
|
||||
for file in glob.iglob("assets/textures/**/*.png", recursive=True):
|
||||
self.__textures[file[16:].replace("\\", "/")] = pygame.image.load(
|
||||
file
|
||||
).convert_alpha(surface)
|
||||
|
||||
# Création du cache pour les polices
|
||||
self.__fonts: dict[int, pygame.font.Font] = {}
|
||||
|
||||
def get_texture(self, name: str) -> pygame.Surface:
|
||||
|
@ -301,7 +294,16 @@ class Assets:
|
|||
Retourne:
|
||||
La texture qui correspond au nom *name*.
|
||||
"""
|
||||
return self.__textures.get(name, self.__error_texture)
|
||||
texture = self.__textures.get(name)
|
||||
if texture is None:
|
||||
if os.path.exists(f"assets/textures/{name}"):
|
||||
texture = pygame.image.load(f"assets/textures/{name}")
|
||||
if not name.startswith("animations/"):
|
||||
texture = texture.convert_alpha()
|
||||
self.__textures[name] = texture
|
||||
return texture
|
||||
return self.__error_texture
|
||||
return texture
|
||||
|
||||
def get_texture_size(self, name: str) -> Vec2:
|
||||
"""
|
||||
|
|
|
@ -10,7 +10,6 @@ from scenes import menu
|
|||
start_game(
|
||||
{
|
||||
"menu": menu.SCENE,
|
||||
"classique": menu.SCENE,
|
||||
},
|
||||
"menu",
|
||||
title="Guess The Number",
|
||||
|
|
|
@ -12,9 +12,6 @@ from engine import (
|
|||
Order,
|
||||
Position,
|
||||
Scene,
|
||||
Sound,
|
||||
Text,
|
||||
TextSize,
|
||||
Texture,
|
||||
World,
|
||||
)
|
||||
|
@ -39,16 +36,6 @@ def __initialize_world(world: World):
|
|||
Initialise le monde du menu.
|
||||
"""
|
||||
world.create_entity(Position(), Order(0), Texture("menu/background.png"))
|
||||
|
||||
world.create_entity(
|
||||
Position(Display.WIDTH / 2, 200),
|
||||
Order(1),
|
||||
Centered(),
|
||||
Text("Guess The Number"),
|
||||
TextSize(200),
|
||||
Sound("pop.ogg", loop=True, callback=lambda _, _a: print("coucou")),
|
||||
)
|
||||
|
||||
scenes_name = ["classique", "menteur", "tricheur", "histoire"]
|
||||
for i, name in enumerate(scenes_name):
|
||||
__create_button(world, i, name)
|
||||
|
|
Loading…
Reference in a new issue