ecs #58
BIN
assets/global/base_game/click.wav
Normal file
BIN
assets/global/base_game/click.wav
Normal file
Binary file not shown.
BIN
assets/global/base_game/lose_sound.wav
Normal file
BIN
assets/global/base_game/lose_sound.wav
Normal file
Binary file not shown.
BIN
assets/global/base_game/win_sound.wav
Normal file
BIN
assets/global/base_game/win_sound.wav
Normal file
Binary file not shown.
|
@ -15,6 +15,7 @@ from plugins.assets import Assets
|
|||
from plugins.hover import HoveredTexture
|
||||
from plugins.inputs import Pressed
|
||||
from plugins.render import Sprite
|
||||
from plugins.sound import Sound
|
||||
from plugins.text import Text
|
||||
from plugins.writing import Writing
|
||||
from plugins.click import Clickable
|
||||
|
@ -151,6 +152,9 @@ def __initialize_world(world: World):
|
|||
|
||||
|
||||
def __key_check(world: World):
|
||||
"""
|
||||
Fonction qui verirife si les touches entrer et entrer du pavé numeriques sont pressées
|
||||
"""
|
||||
pressed = world[Pressed]
|
||||
for key in pressed:
|
||||
if key == "return" or key == "enter":
|
||||
|
@ -158,6 +162,10 @@ def __key_check(world: World):
|
|||
|
||||
|
||||
def __update(world: World):
|
||||
"""
|
||||
Fonction qui update la scene et qui verifie le nombre donné par rapport au nombre chosie
|
||||
"""
|
||||
world.new_entity().set(Sound(world[Assets].get_sound("base_game/click")))
|
||||
# Gestion du pluriel pour le nombre d'essais restants
|
||||
pluriel = "s"
|
||||
if int(world[RemainingAttempts]) == 2:
|
||||
|
@ -194,6 +202,12 @@ def __update(world: World):
|
|||
for response in world.query(Text, Response):
|
||||
response[Text].text = "Gagné !"
|
||||
entity[Text].text = f"Le nombre etait {world[Number]}"
|
||||
|
||||
# On joue le sond e victoire
|
||||
world.new_entity().set(
|
||||
Sound(world[Assets].get_sound("base_game/win_sound"))
|
||||
)
|
||||
|
||||
# Le jeu est finit et on ne peux plus ecrire
|
||||
del world[IsRunning]
|
||||
del entity[Writing]
|
||||
|
@ -244,6 +258,10 @@ def __update(world: World):
|
|||
response[Text].text = "Perdu !"
|
||||
# On affiche le nombre
|
||||
entity[Text].text = f"Le nombre etait {world[Number]}"
|
||||
|
||||
world.new_entity().set(
|
||||
Sound(world[Assets].get_sound("base_game/lose_sound"))
|
||||
)
|
||||
# On change la texure du bouton valider en bouton rejouer
|
||||
for play_again in world.query(PlayAgain):
|
||||
play_again[Sprite].texture = world[Assets].get_texture("play_again")
|
||||
|
|
Loading…
Reference in a new issue