pocket-friends/pocket_friends/surfaces/title.py

38 lines
1.3 KiB
Python

"""Title screen module. Contains the surface object to be rendered on the screen."""
import pygame
from pocket_friends.elements import surface
class Surface(surface.GameSurface):
"""
Surface object for the title screen. Child class of surface.GameSurface.
"""
def __init__(self, game_res: tuple, resources_dir: str, game_fps: int):
"""
Create a title screen surface object.
Args:
game_res: The internal resolution of the surface.
resources_dir: The path of the game's main resource directory.
game_fps: How many frames per second the game will run at.
"""
super().__init__(game_res, resources_dir, game_fps)
self._frames = 0 # Counter for the number of frames passed
self._delay = 1 # Delay in seconds that the title should stay on screen
# Image of the title screen
self._title = pygame.image.load(resources_dir + '/images/title.png').convert_alpha()
def update(self):
"""
Advance the surface logic by one frame.
"""
self.preprocess()
self.blit(self._title, (0, 0))
self._frames += 1
if self._frames > self.game_fps * self._delay:
self.next_surface = 'egg_select'
self.running = False