2023-05-15 00:24:57 -04:00
|
|
|
"""Title screen module. Contains the surface object to be rendered on the screen."""
|
2023-05-11 09:58:44 -04:00
|
|
|
import pygame
|
2023-05-13 13:11:47 -04:00
|
|
|
from pocket_friends.elements import surface
|
2023-05-11 09:58:44 -04:00
|
|
|
|
|
|
|
|
2023-05-13 13:07:33 -04:00
|
|
|
class Surface(surface.GameSurface):
|
2023-05-15 00:24:57 -04:00
|
|
|
"""
|
|
|
|
Surface object for the title screen.
|
|
|
|
"""
|
2023-05-13 13:07:33 -04:00
|
|
|
def __init__(self, game_res, resources_dir, game_fps):
|
2023-05-15 00:24:57 -04:00
|
|
|
"""
|
|
|
|
Create a title screen surface object
|
|
|
|
Args:
|
|
|
|
game_res (int): The internal resolution of the game
|
|
|
|
resources_dir (str): The full path of the game's resource directory
|
|
|
|
game_fps (int): The
|
|
|
|
"""
|
|
|
|
|
2023-05-13 13:07:33 -04:00
|
|
|
super().__init__(game_res, resources_dir, game_fps)
|
2023-05-11 09:58:44 -04:00
|
|
|
|
2023-05-15 00:26:44 -04:00
|
|
|
self._frames = 0
|
|
|
|
self._delay = 1
|
2023-05-11 12:20:07 -04:00
|
|
|
|
2023-05-15 00:26:44 -04:00
|
|
|
self._title = pygame.image.load(resources_dir + '/images/title.png').convert_alpha()
|
2023-05-13 13:07:33 -04:00
|
|
|
|
2023-05-11 09:58:44 -04:00
|
|
|
def update(self):
|
2023-05-13 13:07:33 -04:00
|
|
|
"""
|
|
|
|
Advance the surface logic by one frame.
|
|
|
|
"""
|
|
|
|
self.preprocess()
|
2023-05-15 00:26:44 -04:00
|
|
|
self.blit(self._title, (0, 0))
|
2023-05-11 09:58:44 -04:00
|
|
|
|
2023-05-15 00:26:44 -04:00
|
|
|
self._frames += 1
|
|
|
|
if self._frames > self.game_fps * self._delay:
|
2023-05-11 13:09:55 -04:00
|
|
|
self.next_surface = 'egg_select'
|
|
|
|
self.running = False
|