Sound file error hopefully fixed for pyinstaller.
This commit is contained in:
		| @@ -95,3 +95,26 @@ def get_level_path(game_dir, level_num): | ||||
|  | ||||
|     level_path = os.path.join(base_path, "levels", game_dir, f"{level_num}.json") | ||||
|     return level_path | ||||
|  | ||||
|  | ||||
| def get_game_dir_path(game_dir): | ||||
|     """Get full path to game directory for end.ogg and other game files. | ||||
|      | ||||
|     Args: | ||||
|         game_dir (str): Game directory name | ||||
|          | ||||
|     Returns: | ||||
|         str: Full path to game directory | ||||
|     """ | ||||
|     if game_dir is None: | ||||
|         raise ValueError("game_dir cannot be None") | ||||
|          | ||||
|     # Handle PyInstaller path issues - same logic as get_level_path | ||||
|     if hasattr(sys, "_MEIPASS"): | ||||
|         # Running as PyInstaller executable | ||||
|         base_path = sys._MEIPASS | ||||
|     else: | ||||
|         # Running as script | ||||
|         base_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||||
|          | ||||
|     return os.path.join(base_path, "levels", game_dir) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user