diff --git a/pocket_friends/development/__init__.py b/pocket_friends/_development/__init__.py similarity index 100% rename from pocket_friends/development/__init__.py rename to pocket_friends/_development/__init__.py diff --git a/pocket_friends/development/dev.py b/pocket_friends/_development/_dev.py similarity index 80% rename from pocket_friends/development/dev.py rename to pocket_friends/_development/_dev.py index 1fc799b..e66511e 100644 --- a/pocket_friends/development/dev.py +++ b/pocket_friends/_development/_dev.py @@ -16,4 +16,7 @@ def update(): sys.exit(1) def restart_app(): - sys.exit(1) \ No newline at end of file + sys.exit(1) + +def show_black(): + return 'show_black' \ No newline at end of file diff --git a/pocket_friends/development/sprites.py b/pocket_friends/_development/_sprites.py similarity index 100% rename from pocket_friends/development/sprites.py rename to pocket_friends/_development/_sprites.py diff --git a/pocket_friends/_development/surfaces/_black_screen.py b/pocket_friends/_development/surfaces/_black_screen.py new file mode 100644 index 0000000..8a0f1ad --- /dev/null +++ b/pocket_friends/_development/surfaces/_black_screen.py @@ -0,0 +1,33 @@ +import pygame +from pocket_friends.elements import surface + + +class Surface(surface.GameSurface): + def __init__(self, game_res, resources_dir, game_fps, **kwargs): + super().__init__(game_res, resources_dir, game_fps) + self.game_fps = game_fps + self.frames = -3 * game_fps + self.delay = 1 + self.font = pygame.font.Font(resources_dir + '/fonts/5Pts5.ttf', 10) + self.title = pygame.image.load(resources_dir + '/images/debug/invalid.png').convert_alpha() + self.next_surface = 'title' + + def update(self): + self.preprocess() + self.fill((0, 0, 0)) + + text_1 = self.font.render('Press B', False, (64, 64, 64)) + text_2 = self.font.render('to return', False, (64, 64, 64)) + + if self.frames < 0: + self.blit(text_1, (3, 20)) + self.blit(text_2, (3, 40)) + + self.frames += 1 + if self.frames > self.game_fps: + self.frames = 0 + + for event in pygame.event.get(): + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_b: + self.running = False diff --git a/pocket_friends/development/dev_menu.py b/pocket_friends/_development/surfaces/_dev_menu.py similarity index 83% rename from pocket_friends/development/dev_menu.py rename to pocket_friends/_development/surfaces/_dev_menu.py index 1653954..525352c 100644 --- a/pocket_friends/development/dev_menu.py +++ b/pocket_friends/_development/surfaces/_dev_menu.py @@ -1,13 +1,14 @@ import pygame from pocket_friends.elements import surface -from pocket_friends.development.sprites import FunctionSelector -import pocket_friends.development.dev as dev +from pocket_friends._development._sprites import FunctionSelector +import pocket_friends._development._dev as dev dev_functions = { 'Restart': 'reboot_system', 'Shutdown': 'shutdown_system', 'Update': 'update', - 'Re-open App': 'restart_app' + 'Re-open App': 'restart_app', + 'Black screen': 'show_black' } @@ -29,7 +30,10 @@ class Surface(surface.GameSurface): def execute(self): executing_function = getattr(dev, dev_functions.get(self.function_selector.get_function())) - executing_function() + output = executing_function() + if output == 'show_black': + self.next_surface = '_black_screen' + self.running = False def update(self): self.preprocess() diff --git a/pocket_friends/game.py b/pocket_friends/game.py index 5b1cd15..9ae2f9b 100644 --- a/pocket_friends/game.py +++ b/pocket_friends/game.py @@ -4,7 +4,8 @@ import pocket_friends import importlib valid_surfaces = [ - 'dev_menu', + '_dev_menu', + '_black_screen', 'title', 'egg_select', 'selection_info', @@ -12,12 +13,15 @@ valid_surfaces = [ ] # Add all the surface modules to a dictionary for easy switching -surface_modules = {'dev_menu': importlib.import_module('pocket_friends.development.{0}'.format('dev_menu'))} +surface_modules = {} for module in valid_surfaces: - if module != 'dev_menu': + print(module[0]) + if module[0] == '_': + surface_modules[module] = importlib.import_module('pocket_friends._development.surfaces.{0}'.format(module)) + else: surface_modules[module] = importlib.import_module('pocket_friends.surfaces.{0}'.format(module)) starting_surface = 'title' - +print(surface_modules) # FPS for the game to run at. game_fps = 16 # The internal resolution of the game @@ -65,12 +69,12 @@ def start_game(resolution=240): if not surface.running: if surface.dev_override: - next_surface = 'dev_menu' + next_surface = '_dev_menu' else: next_surface = surface.next_surface additional_args = surface.additional_args if next_surface not in valid_surfaces: - print(next) + print(next_surface) next_surface = 'error_screen' surface = surface_modules.get(next_surface).Surface((game_res, game_res), resources_dir, game_fps, **additional_args)