Dialogues (fais pas chier j'ai trop mal a la tête pour faire une bonne PR) #62

Merged
raphael merged 7 commits from dialogues into main 2023-11-05 12:02:51 +00:00
4 changed files with 14 additions and 2 deletions
Showing only changes of commit cd0b3dee53 - Show all commits

View file

@ -0,0 +1,8 @@
[
"Alors, où te cache tu ???",
"Je vais te trouver !",
"Ou te cache tu ?",
"Mais t'es où enfin !",
"Comment cet idiot fait pour aussi bien se cacher ?",
"Montre toi..."
]

View file

@ -21,7 +21,7 @@ import pyttsx3
engine = pyttsx3.init()
def spawn_dialog(world: World, name: str, height: float = 900):
def spawn_dialog(world: World, name: str, index: int = -1, height: float = 100):
"""
Fait apparaitre un dialogue dans le monde.
"""
@ -29,7 +29,7 @@ def spawn_dialog(world: World, name: str, height: float = 900):
texts: list[str] = json.load(
open(f"assets/dialogs/{name}.json", "r", encoding="utf-8")
)
text = random.choice(texts)
text = random.choice(texts) if index == -1 else texts[index]
# engine.say(text)
engine.save_to_file(text, "voice.mp3")
engine.runAndWait()

View file

@ -177,9 +177,13 @@ def __game_loop(world: World):
La boucle principale de la scène
"""
yield wait(5.0)
dialog_index = 0
for i in range(10):
if i % 2 == 1:
__block_directory(world)
if i in (0, 1, 2, 4, 6, 8):
dialog.spawn_dialog(world, "search", dialog_index)
dialog_index += 1
__spawn_search_alerts(world, int(i / 1.5) + 1)
yield wait(5.0 - (i * 0.4))
__spawn_search_directory(world)

BIN
voice.mp3 Normal file

Binary file not shown.