added black screen to dev menu
This commit is contained in:
parent
f3751def40
commit
86e8c51494
@ -17,3 +17,6 @@ def update():
|
|||||||
|
|
||||||
def restart_app():
|
def restart_app():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def show_black():
|
||||||
|
return 'show_black'
|
33
pocket_friends/_development/surfaces/_black_screen.py
Normal file
33
pocket_friends/_development/surfaces/_black_screen.py
Normal file
@ -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
|
@ -1,13 +1,14 @@
|
|||||||
import pygame
|
import pygame
|
||||||
from pocket_friends.elements import surface
|
from pocket_friends.elements import surface
|
||||||
from pocket_friends.development.sprites import FunctionSelector
|
from pocket_friends._development._sprites import FunctionSelector
|
||||||
import pocket_friends.development.dev as dev
|
import pocket_friends._development._dev as dev
|
||||||
|
|
||||||
dev_functions = {
|
dev_functions = {
|
||||||
'Restart': 'reboot_system',
|
'Restart': 'reboot_system',
|
||||||
'Shutdown': 'shutdown_system',
|
'Shutdown': 'shutdown_system',
|
||||||
'Update': 'update',
|
'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):
|
def execute(self):
|
||||||
|
|
||||||
executing_function = getattr(dev, dev_functions.get(self.function_selector.get_function()))
|
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):
|
def update(self):
|
||||||
self.preprocess()
|
self.preprocess()
|
@ -4,7 +4,8 @@ import pocket_friends
|
|||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
valid_surfaces = [
|
valid_surfaces = [
|
||||||
'dev_menu',
|
'_dev_menu',
|
||||||
|
'_black_screen',
|
||||||
'title',
|
'title',
|
||||||
'egg_select',
|
'egg_select',
|
||||||
'selection_info',
|
'selection_info',
|
||||||
@ -12,12 +13,15 @@ valid_surfaces = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Add all the surface modules to a dictionary for easy switching
|
# 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:
|
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))
|
surface_modules[module] = importlib.import_module('pocket_friends.surfaces.{0}'.format(module))
|
||||||
starting_surface = 'title'
|
starting_surface = 'title'
|
||||||
|
print(surface_modules)
|
||||||
# FPS for the game to run at.
|
# FPS for the game to run at.
|
||||||
game_fps = 16
|
game_fps = 16
|
||||||
# The internal resolution of the game
|
# The internal resolution of the game
|
||||||
@ -65,12 +69,12 @@ def start_game(resolution=240):
|
|||||||
|
|
||||||
if not surface.running:
|
if not surface.running:
|
||||||
if surface.dev_override:
|
if surface.dev_override:
|
||||||
next_surface = 'dev_menu'
|
next_surface = '_dev_menu'
|
||||||
else:
|
else:
|
||||||
next_surface = surface.next_surface
|
next_surface = surface.next_surface
|
||||||
additional_args = surface.additional_args
|
additional_args = surface.additional_args
|
||||||
if next_surface not in valid_surfaces:
|
if next_surface not in valid_surfaces:
|
||||||
print(next)
|
print(next_surface)
|
||||||
next_surface = 'error_screen'
|
next_surface = 'error_screen'
|
||||||
surface = surface_modules.get(next_surface).Surface((game_res, game_res), resources_dir,
|
surface = surface_modules.get(next_surface).Surface((game_res, game_res), resources_dir,
|
||||||
game_fps, **additional_args)
|
game_fps, **additional_args)
|
||||||
|
Loading…
Reference in New Issue
Block a user