Compare commits

...

2 Commits

Author SHA1 Message Date
b6432e233a changed dev menu to white 2023-05-14 17:55:37 -04:00
4249a7c3f1 added preliminary dev menu 2023-05-14 17:47:56 -04:00
4 changed files with 31 additions and 4 deletions

View File

@ -0,0 +1,26 @@
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.frames = 1
self.game_fps = game_fps
self.delay = 1
self.font = pygame.font.Font(resources_dir + '/fonts/5Pts5.ttf', 10)
self.bg = pygame.image.load(self.resource_dir + '/images/dev_bg.png').convert_alpha()
def update(self):
self.preprocess()
text = self.font.render('f: {0}'.format(self.frames), False, (128, 128, 128))
self.blit(text, (3, 68))
self.frames += 1
self.frames %= self.game_fps
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_b:
self.running = False

View File

@ -12,6 +12,7 @@ class GameSurface(pygame.Surface):
resource_dir (:obj:`str`): The path of the game's main resource directory.
game_fps (int): How many frames per second the game will run at.
additional_args (dict): Additional arguments to send to the next surface after halting.
bg (:obj:`pygame.Surface`): The background of the surface.
"""
def __init__(self, game_res, resources_dir, game_fps):
"""
@ -30,7 +31,7 @@ class GameSurface(pygame.Surface):
self._input_handler = InputHandler(self._clock)
self.additional_args = {}
self._bg = pygame.image.load(self.resource_dir + '/images/bg.png').convert_alpha()
self.bg = pygame.image.load(self.resource_dir + '/images/bg.png').convert_alpha()
self.sprites = pygame.sprite.Group()
def preprocess(self):
@ -39,7 +40,7 @@ class GameSurface(pygame.Surface):
"""
self._clock.tick(self.game_fps)
self.blit(self._bg, (0, 0))
self.blit(self.bg, (0, 0))
self.sprites.update()
self.sprites.draw(self)

View File

@ -12,7 +12,7 @@ valid_surfaces = [
]
# Add all the surface modules to a dictionary for easy switching
surface_modules = {}
surface_modules = {'dev_menu': importlib.import_module('pocket_friends.development.{0}'.format('dev_menu'))}
for module in valid_surfaces:
surface_modules[module] = importlib.import_module('pocket_friends.surfaces.{0}'.format(module))
starting_surface = 'title'
@ -66,7 +66,7 @@ def start_game(resolution=240):
next_surface = surface.next_surface
additional_args = surface.additional_args
if next_surface not in valid_surfaces:
next_surface = 'error_screen'
next_surface = 'dev_menu'
surface = surface_modules.get(next_surface).Surface((game_res, game_res), resources_dir,
game_fps, **additional_args)
pygame.display.flip()

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB