diff --git a/res/locale/fr.yaml b/res/locale/fr/fr.yaml similarity index 100% rename from res/locale/fr.yaml rename to res/locale/fr/fr.yaml diff --git a/res/locale/fr/select.yaml b/res/locale/fr/select.yaml new file mode 100644 index 0000000..40b9a41 --- /dev/null +++ b/res/locale/fr/select.yaml @@ -0,0 +1,33 @@ +1 : + qu: "Citer les hypothèses du CSSA pour la convergence de la série Σun." + keys: "mathsern" + a : "(|un|) est bornée" + b : "(un) décroît" + c : "(|un|) décroît" + d : "(|un|) tend vers 0" + e : "(|un|) est équivalente à 1/n" + correct: !!set + ? 'c' + ? 'd' + +2 : + qu: "Sélectionner la bonne valeur de h/2π." + keys: "physquan" + a : "1,05.10E-34 J.s" + b : "1,05.10E-34 J/s" + c : "1,05.10E-35 J.s" + d : "1,05.10E-35 J/s" + e : "1,05.10E-35 J.s²" + correct: !!set + ? 'a' + +3 : + qu: "Complexité de l'algorithme de DIJKSTRA." + keys: "infogrph" + a : "Θ(n²)" + b : "Θ(n³)" + c : "Θ(n log(n))" + d : "Θ(exp(n))" + e : "Θ(n⁴)" + correct: !!set + ? 'b' \ No newline at end of file diff --git a/res/maps/l101.tmx b/res/maps/l101.tmx index 62ce866..f772dc2 100644 --- a/res/maps/l101.tmx +++ b/res/maps/l101.tmx @@ -1,5 +1,5 @@ - + @@ -59,8 +59,8 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147483654,63,63,63,63,63,63,63,63,63,63,63,63,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147483654,63,63,63,63,63,63,63,63,63,63,63,63,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147483654,63,63,63,63,63,63,63,63,63,63,63,63,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,63,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147483654,63,63,63,63,63,63,63,63,63,63,63,63,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -213,11 +213,12 @@ - - + + + diff --git a/res/textures/minigame/select/arrow.png b/res/textures/minigame/select/arrow.png new file mode 100644 index 0000000..44b0346 Binary files /dev/null and b/res/textures/minigame/select/arrow.png differ diff --git a/res/textures/minigame/select/choiceoff.png b/res/textures/minigame/select/choiceoff.png new file mode 100644 index 0000000..36c574d Binary files /dev/null and b/res/textures/minigame/select/choiceoff.png differ diff --git a/res/textures/minigame/select/choiceon.png b/res/textures/minigame/select/choiceon.png new file mode 100644 index 0000000..37f0b1b Binary files /dev/null and b/res/textures/minigame/select/choiceon.png differ diff --git a/res/textures/minigame/select/greenbg.png b/res/textures/minigame/select/greenbg.png new file mode 100644 index 0000000..91b3cf5 Binary files /dev/null and b/res/textures/minigame/select/greenbg.png differ diff --git a/res/textures/minigame/select/orangebg.png b/res/textures/minigame/select/orangebg.png new file mode 100644 index 0000000..ad899a6 Binary files /dev/null and b/res/textures/minigame/select/orangebg.png differ diff --git a/res/textures/minigame/select/redbg.png b/res/textures/minigame/select/redbg.png new file mode 100644 index 0000000..479b5cb Binary files /dev/null and b/res/textures/minigame/select/redbg.png differ diff --git a/res/textures/minigame/select/violetbg.png b/res/textures/minigame/select/violetbg.png new file mode 100644 index 0000000..dee5674 Binary files /dev/null and b/res/textures/minigame/select/violetbg.png differ diff --git a/res/textures/tiles.png b/res/textures/tiles.png index b8a7cbf..5b749eb 100644 Binary files a/res/textures/tiles.png and b/res/textures/tiles.png differ diff --git a/src/game.py b/src/game.py index 539e025..d5e846b 100644 --- a/src/game.py +++ b/src/game.py @@ -20,6 +20,7 @@ import menu import debug import scriptmanager as sm +import minigame as mgm class Game: DATABASE_LOCATION = "res/game_data.db" @@ -81,6 +82,7 @@ def __init__(self): self.script_manager = sm.ScriptManager(self) self.map_manager = maps.MapManager(self.screen, self) self.menu_manager = menu.MenuManager(self.screen, self) + self.mgm_manager = mgm.MGManager(self) self.dialogue = None # Contient le dialogue s'il existe @@ -118,6 +120,7 @@ def tick(self): self.menu_manager.draw() self.player.update() self.script_manager.update() # Actualisation du mouvement d'un script : toutes commandes bloquées + self.mgm_manager.update() if self.dialogue != None: self.dialogue.update() # Met à jour le dialogue if self.debug: diff --git a/src/inputs.py b/src/inputs.py index 23f5140..39bd83c 100644 --- a/src/inputs.py +++ b/src/inputs.py @@ -33,14 +33,24 @@ def handle_key_down_event(game, event): game.menu_manager.open_menu() elif event.key == controls["MENU_CANCEL"]: game.menu_manager.close_menu() - elif event.key == controls["MENU_MOVE_UP"]: + elif event.key == controls["MENU_MOVE_UP"] and game.menu_is_open: game.menu_manager.menu_move("up") - elif event.key == controls["MENU_MOVE_DOWN"]: + elif event.key == controls["MENU_MOVE_DOWN"] and game.menu_is_open: game.menu_manager.menu_move("down") - elif event.key == controls["MENU_MOVE_LEFT"]: + elif event.key == controls["MENU_MOVE_LEFT"] and game.menu_is_open: game.menu_manager.menu_move("left") - elif event.key == controls["MENU_MOVE_RIGHT"]: + elif event.key == controls["MENU_MOVE_RIGHT"] and game.menu_is_open: game.menu_manager.menu_move("right") + elif event.key == controls["MINIGAME_UP"] and game.minigame_opened: + game.mgm_manager.key("up") + elif event.key == controls["MINIGAME_DOWN"] and game.minigame_opened: + game.mgm_manager.key("down") + elif event.key == controls["MINIGAME_LEFT"] and game.minigame_opened: + game.mgm_manager.key("left") + elif event.key == controls["MINIGAME_RIGHT"] and game.minigame_opened: + game.mgm_manager.key("right") + elif event.key == controls["MINIGAME_ENTER"] and game.minigame_opened: + game.mgm_manager.key("enter") elif event.key == controls["GAME_FULLSCREEN"]: game.change_window_size(fullscreen = (not game.is_fullscreen)) elif event.key == controls["GAME_TERMINATE"]: diff --git a/src/locale.py b/src/locale.py index b15afc8..7105f93 100644 --- a/src/locale.py +++ b/src/locale.py @@ -4,8 +4,19 @@ import yaml -LOCALE_DIR = "res/locale/" CURRENT_LANGUAGE = "fr" +LOCALE_DIR = f"res/locale/{CURRENT_LANGUAGE}/" + +def get_dir(): + """Retourne l'emplacement des fichiers de traduction""" + return(LOCALE_DIR) + + +def get_string(file, str_id): + with open(f"{LOCALE_DIR}{file}.yaml", 'r', encoding = "utf-8") as file: + strings = yaml.load(file, Loader = yaml.FullLoader) + return(strings[str_id]) + def getstring_dialogue(str_id): with open(f"{LOCALE_DIR}{CURRENT_LANGUAGE}.yaml", 'r', encoding = "utf-8") as file: diff --git a/src/minigame.py b/src/minigame.py new file mode 100644 index 0000000..a16fe40 --- /dev/null +++ b/src/minigame.py @@ -0,0 +1,224 @@ +import pygame as pg + +import locale +import menu +import dialogue + +class MGManager(): + """Classe de gestion des mini-jeux""" + + def __init__(self, game): + self.game = game + self.running_mg = None + + def update(self): + if self.running_mg is not None: + self.game.player.can_move = False + self.game.minigame_opened = True + self.running_mg.update_graphics() + else: + if not self.game.menu_is_open: + self.game.player.can_move = True + self.game.minigame_opened = False + + def launch(self, mgm, *args): + """Lancement d'un mini-jeu passé en argument""" + if mgm == "select": + texts = locale.get_string("select", args[0]) + self.running_mg = SelectGame(self.game, texts["qu"], [texts[p] for p in ['a', 'b', 'c', 'd', 'e']], texts["correct"]) + + def key(self, key): + """Gestion de l'appui d'une touche""" + try: + if key == "up": + self.running_mg.up() + if key == "down": + self.running_mg.down() + if key == "left": + self.running_mg.left() + if key == "right": + self.running_mg.right() + if key == "enter": + self.running_mg.enter() + except AttributeError: + pass # Touche non supportée dans le mini-jeu courant ou pas de mini-jeu + +class Minigame(): + """Classe des mini-jeux""" + + def __init__(self, game): + self.game = game + + def launch(self): + """Exécute un mini-jeu""" + self.game.mgm_manager.running_mg = self + + def terminate(self): + """Arrête l'exécution d'un mini-jeu""" + self.game.mgm_manager.running_mg = None + + +class SelectGame(Minigame): + """Classe du mini-jeu de sélection""" + BANK = f"{locale.get_dir()}/select.yaml" + TEXTURES_FOLDER = "res/textures/minigame/select/" + OFFSET_FROM_BORDER = 30 + OFFSET_TO_BOTTOM = 30 + SPACE_BETWEEN_LINES = 42 + ALPHABET = "abcdefghijklmnopqrstuvwxyz" + FONT = "consolas" + QUESTION_FSIZE = 22 # à remplacer par du LaTeΧ ? + PROPOSITION_FSIZE = 16 + + + def __init__(self, game, question, props, correct): + super().__init__(game) + + self.bgm = "it's concours time" + self.question = question + self.props = props + self.correct = correct + + # Mémoire interne + self.choices = [0 for _ in self.props] + self.cursor_position = 0 # Position du curseur de sélection + + # Graphiques : textures de la boîte d'affichage de la question + self.greenbox = pg.image.load(f"{self.TEXTURES_FOLDER}greenbg.png").convert() + self.greenbox.set_colorkey([255, 255, 255]) + self.orangebox = pg.image.load(f"{self.TEXTURES_FOLDER}orangebg.png").convert() + self.orangebox.set_colorkey([255, 255, 255]) + self.redbox = pg.image.load(f"{self.TEXTURES_FOLDER}redbg.png").convert() + self.redbox.set_colorkey([255, 255, 255]) + self.violetbox = pg.image.load(f"{self.TEXTURES_FOLDER}violetbg.png").convert() + self.violetbox.set_colorkey([255, 255, 255]) + # Police associée + self.qu_font = pg.font.SysFont(self.FONT, self.QUESTION_FSIZE) + self.qu_font_width = max([metric[1] for metric in self.qu_font.metrics("azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN")]) # Chasse maximale pour la police choisie + self.qu_row_length = self.greenbox.get_size()[0] / self.qu_font_width - 7 # cf dialogue + self.qu_row_height = self.qu_font.get_linesize() + # Texte de la question + self.qu_texts = [] + for line in self.format(self.question): + self.qu_texts.append(self.qu_font.render(line, True, [0, 0, 0])) + + # Graphiques : textures des boîtes de sélection + self.choiceoff = pg.image.load(f"{self.TEXTURES_FOLDER}choiceoff.png").convert() + self.choiceoff.set_colorkey([255, 255, 255]) + self.choiceon = pg.image.load(f"{self.TEXTURES_FOLDER}choiceon.png").convert() + self.choiceon.set_colorkey([255, 255, 255]) + self.validate = pg.image.load(f"{self.TEXTURES_FOLDER}choiceoff.png").convert() + self.validate.set_colorkey([255, 255, 255]) + # Police associée + self.prop_font = pg.font.SysFont(self.FONT, self.PROPOSITION_FSIZE) + self.prop_font_width = max([metric[1] for metric in self.prop_font.metrics("azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN")]) # Chasse maximale pour la police choisie + self.row_length = self.greenbox.get_size()[0] / self.prop_font_width - 7 # cf dialogue + self.row_height = self.prop_font.get_linesize() + # Textes des propositions + self.props_tex = [] + for prop in self.props: + self.props_tex.append(self.prop_font.render(prop, True, [0, 0, 0])) + self.props_tex.append(self.prop_font.render("Valider", True, [0, 0, 0])) + + # Graphiques : flèche + self.arrow_tex = pg.image.load(f"{self.TEXTURES_FOLDER}arrow.png").convert() + self.arrow_tex.set_colorkey([255, 255, 255]) + + def down(self): + self.cursor_position += 1 + if self.cursor_position == len(self.props) + 1: # On prend en compte le bouton valider + self.cursor_position = 0 + + def up(self): + self.cursor_position -= 1 + if self.cursor_position == -1: + self.cursor_position = len(self.props) + + def enter(self): + if self.cursor_position == 5: # Dans tous les cas (moins de 5 propositions...) le bouton valider est en 6ème position + answer = set([self.ALPHABET[i] for i in range(len(self.choices)) if self.choices[i] == 1]) + if answer == self.correct: + self.game.script_manager.change_event("passedSelectMG", 1) + else: + self.game.script_manager.change_event("passedSelectMG", 0) + self.terminate() + else: + self.choices[self.cursor_position] = 1 - self.choices[self.cursor_position] + + def format(self, text): + """Découpage d'un texte en plusieurs lignes de taille adéquate""" + formatted_text = [] + splitted_text = text.split() + text_line = "" + line_length = 0 + while splitted_text != []: + word_length = len(splitted_text[0]) + if line_length + word_length > self.qu_row_length: + formatted_text.append(text_line) + text_line = "" + line_length = 0 + text_line += splitted_text[0] + " " + line_length += word_length + 1 + del(splitted_text[0]) + formatted_text.append(text_line) + return(formatted_text) + + def update_graphics(self): + """Mise à jour de l'affichage des textures des boutons et de la boîte de dialogue""" + # Affichage de la boîte de question + rect_box = self.greenbox.get_rect(center=(self.game.screen.get_size()[0]/2, self.OFFSET_FROM_BORDER + self.greenbox.get_size()[1]/2)) + self.game.screen.blit(self.greenbox, rect_box) + for line in range(len(self.qu_texts)): + text_box = self.qu_texts[line].get_rect(center = (self.game.screen.get_size()[0]/2, self.OFFSET_FROM_BORDER + self.greenbox.get_size()[1]/2 + (line-len(self.qu_texts)/2) * self.qu_row_height)) + self.game.screen.blit(self.qu_texts[line], text_box) + + # Affichage des boîtes de choix + rect_A = self.choiceoff.get_rect(center = (self.game.screen.get_size()[0]/2, self.game.screen.get_size()[1] - self.OFFSET_FROM_BORDER - 5*self.SPACE_BETWEEN_LINES - self.choiceoff.get_size()[1]/2)) + if self.choices[0]: + self.game.screen.blit(self.choiceon, rect_A) + else: + self.game.screen.blit(self.choiceoff, rect_A) + text_box = self.props_tex[0].get_rect(center = rect_A.center) + self.game.screen.blit(self.props_tex[0], text_box) + + rect_B = self.choiceoff.get_rect(center = (self.game.screen.get_size()[0]/2, self.game.screen.get_size()[1] - self.OFFSET_FROM_BORDER - 4*self.SPACE_BETWEEN_LINES - self.choiceoff.get_size()[1]/2)) + if self.choices[1]: + self.game.screen.blit(self.choiceon, rect_B) + else: + self.game.screen.blit(self.choiceoff, rect_B) + text_box = self.props_tex[1].get_rect(center = rect_B.center) + self.game.screen.blit(self.props_tex[1], text_box) + + rect_C = self.choiceoff.get_rect(center = (self.game.screen.get_size()[0]/2, self.game.screen.get_size()[1] - self.OFFSET_FROM_BORDER - 3*self.SPACE_BETWEEN_LINES - self.choiceoff.get_size()[1]/2)) + if self.choices[2]: + self.game.screen.blit(self.choiceon, rect_C) + else: + self.game.screen.blit(self.choiceoff, rect_C) + text_box = self.props_tex[2].get_rect(center = rect_C.center) + self.game.screen.blit(self.props_tex[2], text_box) + + rect_D = self.choiceoff.get_rect(center = (self.game.screen.get_size()[0]/2, self.game.screen.get_size()[1] - self.OFFSET_FROM_BORDER - 2*self.SPACE_BETWEEN_LINES - self.choiceoff.get_size()[1]/2)) + if self.choices[3]: + self.game.screen.blit(self.choiceon, rect_D) + else: + self.game.screen.blit(self.choiceoff, rect_D) + text_box = self.props_tex[3].get_rect(center = rect_D.center) + self.game.screen.blit(self.props_tex[3], text_box) + + rect_E = self.choiceoff.get_rect(center = (self.game.screen.get_size()[0]/2, self.game.screen.get_size()[1] - self.OFFSET_FROM_BORDER - self.SPACE_BETWEEN_LINES - self.choiceoff.get_size()[1]/2)) + if self.choices[4]: + self.game.screen.blit(self.choiceon, rect_E) + else: + self.game.screen.blit(self.choiceoff, rect_E) + text_box = self.props_tex[4].get_rect(center = rect_E.center) + self.game.screen.blit(self.props_tex[4], text_box) + + rect_val = self.choiceoff.get_rect(center = (self.game.screen.get_size()[0]/2, self.game.screen.get_size()[1] - self.OFFSET_FROM_BORDER - self.choiceoff.get_size()[1]/2)) + self.game.screen.blit(self.choiceoff, rect_val) + text_box = self.props_tex[5].get_rect(center = rect_val.center) + self.game.screen.blit(self.props_tex[5], text_box) + + # Affichage de la flèche + rect_arrow = self.arrow_tex.get_rect(center = (self.game.screen.get_size()[0]/2 - self.choiceoff.get_size()[0]/2 + 20, # Terme correctif + self.game.screen.get_size()[1] - self.OFFSET_TO_BOTTOM - (5 - self.cursor_position)*self.SPACE_BETWEEN_LINES - self.choiceoff.get_size()[1]/2)) + self.game.screen.blit(self.arrow_tex, rect_arrow) \ No newline at end of file diff --git a/src/scriptmanager.py b/src/scriptmanager.py index cfa748b..286322e 100644 --- a/src/scriptmanager.py +++ b/src/scriptmanager.py @@ -11,6 +11,7 @@ import menu import scripts import dialogue as dia +import minigame as mgm class ScriptManager(): """Classe de gestion des scripts du jeu""" @@ -124,7 +125,7 @@ def update(self): dist = ((self.initial_coords[0] - self.game.player.position[0])**2 + (self.initial_coords[1] - self.game.player.position[1])**2) ** 0.5 # Distance totale parcourue pendant le script if dist > self.movement_boundary or self.game.player.boop: # Le mouvement s'est déroulé normalement ou le joueur s'est pris un mur self.exit_movingscript() - elif self.game.dialogue is not None or self.game.menu_manager.choicebox is not None: # On laisse le dialogue défiler s'il existe, ou ou attend les résultats de la choicebox + elif self.game.dialogue is not None or self.game.menu_manager.choicebox is not None or self.game.mgm_manager.running_mg is not None: # On laisse le dialogue défiler s'il existe, ou ou attend les résultats de la choicebox pass elif self.current_script_command() >= len(self.game.running_script.contents) or self.abort: # Le script courant est terminé ou on force l'arrêt del(self.game.script_tree[-1]) @@ -289,7 +290,7 @@ def math(self, operator, operand): # Fonctions sonores def chg_music(self, track): """Changement de la musique courante""" - self.game.map_manager.sound_manager.play_music(track) + self.game.map_manager.sound_manager.play_music(track, track) def sfx(self, fx): """Joue un effet sonore""" @@ -356,4 +357,10 @@ def checknpcflag(self, npc, flag_id): def setnpcflag(self, npc, flag_id, state): """Mise à jour du flag d'un NPC""" - self.write_npcflags(npc.id, flag_id, state) \ No newline at end of file + self.write_npcflags(npc.id, flag_id, state) + + # Fonctions des minijeux + # ! WIP + def launchmgm(self, mgm, *args): + """Lancement d'un mini-jeu""" + self.game.mgm_manager.launch(mgm, *args) \ No newline at end of file diff --git a/src/scripts.py b/src/scripts.py index 1c377c3..53af906 100644 --- a/src/scripts.py +++ b/src/scripts.py @@ -77,23 +77,18 @@ def ordinaryNpc(): return(["""dialogue(self.current_npc, 1)"""]) def debug(): - return(["""loadtext('début')""", + return(["""chg_music("it's concours time")""", + + """label('main')""", + """ran(1, 3)""", + """launchmgm("select", self.acc)""", + """checkevent('passedSelectMG')""", + """iftrue("loadtext('''bravo''')")""", + """iffalse("sfx('mighty_button')")""", + """iffalse("loadtext('''t'es nul''')")""", """infobox()""", - """goto('lbl2')""", - - """label('lbl1')""", - """loadtext('label 1')""", - """infobox()""", - """goto('end')""", - - """label('lbl2')""", - """loadtext('label 2')""", - """infobox()""", - """goto('lbl1')""", - - """label('end')""", - """loadtext('fin')""", - """infobox()"""]) + """iftrue("goto('main')")""", + """chg_music(-1)"""]) def dummyScript(): return(["""testflag(12101, 0)""", diff --git a/src/sound.py b/src/sound.py index 9a63005..47f4466 100644 --- a/src/sound.py +++ b/src/sound.py @@ -13,12 +13,17 @@ def __init__(self, map, old_bgm): self.map = map self.channel1 = pg.mixer.Channel(1) self.music_file = self.map.game.game_data_db.execute("select music from maps where id = ?;", (self.map.map_id,)).fetchall()[0][0] - + self.current_music = self.music_file + self.play_music(self.music_file, self.old_bgm) def play_music(self, music_file, old_bgm): """Joue une nouvelle musique""" - if old_bgm is None or old_bgm != self.music_file: # Même bande sonore ou première map chargée pendant la session + if music_file == -1: + pg.mixer.music.load(f"{self.SOUNDS_FOLDER}music/{self.music_file}.mp3") + pg.mixer.music.set_volume(self.VOLUME) + pg.mixer.music.play(-1) + elif old_bgm is None or old_bgm != self.music_file: # Même bande sonore ou première map chargée pendant la session pg.mixer.music.load(f"{self.SOUNDS_FOLDER}music/{music_file}.mp3") pg.mixer.music.set_volume(self.VOLUME) pg.mixer.music.play(-1) # Boucle la musique