updated docstrings and comments

This commit is contained in:
Nicholas Dyer 2023-05-15 01:04:45 -04:00
parent 9fd2bc03df
commit 8675caaca6
4 changed files with 31 additions and 15 deletions

View File

@ -44,7 +44,7 @@ class GameSurface(pygame.Surface):
def preprocess(self):
"""
Advance the surface by one frame and draw the background.
Draw the surface background and advance all the surface's sprites by one frame; Run the input handler.
"""
self._clock.tick(self.game_fps)

View File

@ -1,3 +1,5 @@
"""Main module for the game. Runs setting up the Pygame window and handles scene switching."""
import pygame
import os
import pocket_friends
@ -33,13 +35,13 @@ resources_dir = script_dir + '/resources'
os.environ['SDL_FBDEV'] = '/dev/fb1'
def start_game(resolution, dev):
def start_game(resolution: int, dev: bool):
"""
Starts the game.
Args:
resolution (int, optional): Resolution to display the game at. Defaults to 240.
dev (bool): Boolean to enable the developer menu at start or not
resolution: Resolution to display the game at.
dev: Boolean to enable the developer menu at start or not
"""
pygame.init()

View File

@ -7,7 +7,22 @@ from pocket_friends.elements import surface
class Surface(surface.GameSurface):
def __init__(self, game_res, resources_dir, game_fps, **kwargs):
"""
Surface object for the selection info screen. Contains the selected egg, egg properties, and description in a
scrollable text box. Child class of surface.GameSurface.
"""
def __init__(self, game_res: tuple, resources_dir: str, game_fps: int, **kwargs: str):
"""
Create a selection info 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.
Keyword Args:
selected_egg: The egg that was selected by the previous screen.
"""
super().__init__(game_res, resources_dir, game_fps)
self._selected_egg = None
@ -25,7 +40,7 @@ class Surface(surface.GameSurface):
def update(self):
"""
Advance the surface logic by one frame.
Draw objects on the screen and advance the surface logic by one frame; Handle user input.
"""
self.preprocess()
@ -35,10 +50,8 @@ class Surface(surface.GameSurface):
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN:
# Scroll down on the info screen.
self._info_text.scroll_down()
if event.key == pygame.K_UP:
# Scroll up on the info screen.
self._info_text.scroll_up()
if event.key == pygame.K_a:
self.running = False

View File

@ -5,22 +5,23 @@ from pocket_friends.elements import surface
class Surface(surface.GameSurface):
"""
Surface object for the title screen.
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
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
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
self._delay = 1
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):