Merge branch 'main' into sound

This commit is contained in:
CoCo_Sol 2023-10-29 13:08:00 +01:00
commit 492f3c180f
6 changed files with 13 additions and 25 deletions

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View file

@ -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:
"""

View file

@ -10,7 +10,6 @@ from scenes import menu
start_game(
{
"menu": menu.SCENE,
"classique": menu.SCENE,
},
"menu",
title="Guess The Number",

View file

@ -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)