Compare commits
No commits in common. "b6432e233ad7cf1d0237c82741f0f6594a1a988e" and "187baf6f3e6c51d1a0ce8b5ad4b8b670928f0484" have entirely different histories.
b6432e233a
...
187baf6f3e
@ -1,26 +0,0 @@
|
|||||||
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
|
|
@ -12,7 +12,6 @@ class GameSurface(pygame.Surface):
|
|||||||
resource_dir (:obj:`str`): The path of the game's main resource directory.
|
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.
|
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.
|
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):
|
def __init__(self, game_res, resources_dir, game_fps):
|
||||||
"""
|
"""
|
||||||
@ -31,7 +30,7 @@ class GameSurface(pygame.Surface):
|
|||||||
self._input_handler = InputHandler(self._clock)
|
self._input_handler = InputHandler(self._clock)
|
||||||
self.additional_args = {}
|
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()
|
self.sprites = pygame.sprite.Group()
|
||||||
|
|
||||||
def preprocess(self):
|
def preprocess(self):
|
||||||
@ -40,7 +39,7 @@ class GameSurface(pygame.Surface):
|
|||||||
"""
|
"""
|
||||||
self._clock.tick(self.game_fps)
|
self._clock.tick(self.game_fps)
|
||||||
|
|
||||||
self.blit(self.bg, (0, 0))
|
self.blit(self._bg, (0, 0))
|
||||||
self.sprites.update()
|
self.sprites.update()
|
||||||
self.sprites.draw(self)
|
self.sprites.draw(self)
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ 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:
|
||||||
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'
|
||||||
@ -66,7 +66,7 @@ def start_game(resolution=240):
|
|||||||
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:
|
||||||
next_surface = 'dev_menu'
|
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)
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB |
Loading…
Reference in New Issue
Block a user