updated comments and docstrings
This commit is contained in:
parent
86e8c51494
commit
f765bb3dcb
@ -6,21 +6,27 @@ from ..io.input_handler import InputHandler
|
||||
class GameSurface(pygame.Surface):
|
||||
"""
|
||||
Class to be used as the backbone of all game surfaces.
|
||||
|
||||
The GameSurface class is what the game uses to draw all other elements on top of. It controls a number of game
|
||||
operations, including input handling, frame rate limiting, and surface switching. It is a child class of Pygame's
|
||||
Surface class and utilizes Pygame's sprite handling along with the ability to blit certain things on the screen
|
||||
in order to draw elements easily.
|
||||
|
||||
Attributes:
|
||||
running (bool): Boolean to tell whether the surface is running or not.
|
||||
next_surface (:obj:`str`): What the next surface should be after halting.
|
||||
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.
|
||||
running: Boolean to tell whether the surface is running or not.
|
||||
next_surface: String that represents the next surface to be switched to after halting.
|
||||
resource_dir: String that contains the path of the game's main resource directory.
|
||||
game_fps: An integer value of how many frames per second the game will run at.
|
||||
additional_args: Dictionary of additional arguments to send to the next surface after halting.
|
||||
background: A Pygame surface that will be drawn behind all other elements.
|
||||
"""
|
||||
def __init__(self, game_res, resources_dir, game_fps):
|
||||
def __init__(self, game_res: int, resources_dir: str, game_fps: pygame.Surface):
|
||||
"""
|
||||
Create a GameSurface object.
|
||||
Args:
|
||||
game_res (int): The internal resolution of the surface.
|
||||
resources_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_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, pygame.SRCALPHA)
|
||||
self.running = True
|
||||
|
@ -1,3 +1,6 @@
|
||||
"""Module for selection info. Shows egg stats after an egg has been selected from the starting
|
||||
screen. Contains the surface object to be rendered."""
|
||||
|
||||
import pygame
|
||||
from pocket_friends.elements import sprites
|
||||
from pocket_friends.elements import surface
|
||||
@ -26,6 +29,9 @@ class Surface(surface.GameSurface):
|
||||
self.info_icons = sprites.EggInfo(resources_dir, egg.contentedness, egg.metabolism, (32, 4))
|
||||
|
||||
def update(self):
|
||||
"""
|
||||
Advance the surface logic by one frame.
|
||||
"""
|
||||
self.preprocess()
|
||||
|
||||
self.info_text.draw(self)
|
||||
|
@ -1,9 +1,21 @@
|
||||
"""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.
|
||||
"""
|
||||
def __init__(self, game_res, resources_dir, game_fps):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
super().__init__(game_res, resources_dir, game_fps)
|
||||
|
||||
self.frames = 0
|
||||
|
Loading…
Reference in New Issue
Block a user