def initGame(game_path, window = False, first_scene = "begin.txt", skip_intro = False): global gameObject scene_folder = os.path.join(game_path, "scenes") print(("Scene folder: " + scene_folder)) if not os.path.exists(scene_folder): print("Missing scene folder") sys.exit(3) intro_file = os.path.join(scene_folder, "intro.txt") if os.path.exists(intro_file): lines = filehelper.readLines(intro_file) for line in lines: if line.startswith("file "): video_file = line[5:].strip() video_file = os.path.join(game_path, "videos", video_file) if not os.path.exists(video_file): print(("Video file " + video_file + " not found!")) elif not skip_intro: videoplay.play(video_file, window) pygame.init() if android: android.map_key(android.KEYCODE_BACK, pygame.K_ESCAPE) android.map_key(android.KEYCODE_MENU, pygame.K_F10) gameObject = scene.Scene(game_path, scene_folder, first_scene, window)
def loadDialog(self): if not self.character in self.parent.previous_dialogs: self.parent.previous_dialogs[self.character] = {"name" : self.name, "answers" : []} self.first_talk = True self.dialog = OrderedDict() self.intro = None section = None name = None text = None image = None media_type = "video" intro_video = None intro2_video = None if not os.path.exists(self.character_file): raise Exception("Chracter file " + self.character_file + " doesn't exists") lines = filehelper.readLines(self.character_file) for line in lines: if line.startswith(":"): if section != None: pass section = line[1:] if not self.first_section: self.first_section = section text = None if not section in self.dialog: self.dialog[section] = OrderedDict() elif line.startswith("first section "): self.first_section = line[14:] elif line.startswith("intro "): intro_video = line[6:].strip() elif line.startswith("image ") and not section: image = line[6:].strip() elif line.startswith("intro2 "): intro2_video = line[7:].strip() elif line.startswith("media_type ") or line.startswith("media type "): media_type = line[11:].strip() elif line.startswith("-") and section: text = line[2:].strip() self.dialog[section][text] = {} self.dialog[section][text]["once"] = False self.dialog[section][text]["sub"] = section self.dialog[section][text]["action"] = None elif line.startswith("leave") and text: self.dialog[section][text]["sub"] = None elif line.startswith("video ") and text: self.dialog[section][text]["video"] = line[6:].strip() elif line.startswith("name ") and text: self.dialog[section][text]["name"] = line[5:].strip() elif line.startswith("audio ") and text: self.dialog[section][text]["audio"] = line[6:].strip() elif line.startswith("sub") and text: self.dialog[section][text]["sub"] = line[4:].strip() elif line.startswith("exec") and text: self.dialog[section][text]["exec"] = line[5:].strip() elif line.startswith("once") and text: self.dialog[section][text]["once"] = True elif line.startswith("action") and text: self.dialog[section][text]["action"] = line[7:].strip() if image: image = os.path.join(self.image_dir, image) if os.path.exists(image): print("Loading character image") self.character_image = pygame.image.load(image) else: print((image + " not found")) self.character_image = None else: self.character_image = None print("No character image set (skipping)") if intro2_video and not self.first_talk: if media_type == "video": self.playCutscene(intro2_video) elif media_type == "audio": self.playAudioFile(intro2_video) elif intro_video: if media_type == "video": self.playCutscene(intro_video) elif media_type == "audio": self.playAudioFile(intro_video) self.section = self.first_section self.running = True