updated docstrings and comments
This commit is contained in:
parent
9fd2bc03df
commit
8675caaca6
@ -44,7 +44,7 @@ class GameSurface(pygame.Surface):
|
|||||||
|
|
||||||
def preprocess(self):
|
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)
|
self._clock.tick(self.game_fps)
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Main module for the game. Runs setting up the Pygame window and handles scene switching."""
|
||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
import os
|
import os
|
||||||
import pocket_friends
|
import pocket_friends
|
||||||
@ -33,13 +35,13 @@ resources_dir = script_dir + '/resources'
|
|||||||
os.environ['SDL_FBDEV'] = '/dev/fb1'
|
os.environ['SDL_FBDEV'] = '/dev/fb1'
|
||||||
|
|
||||||
|
|
||||||
def start_game(resolution, dev):
|
def start_game(resolution: int, dev: bool):
|
||||||
"""
|
"""
|
||||||
Starts the game.
|
Starts the game.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
resolution (int, optional): Resolution to display the game at. Defaults to 240.
|
resolution: Resolution to display the game at.
|
||||||
dev (bool): Boolean to enable the developer menu at start or not
|
dev: Boolean to enable the developer menu at start or not
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
@ -7,7 +7,22 @@ from pocket_friends.elements import surface
|
|||||||
|
|
||||||
|
|
||||||
class Surface(surface.GameSurface):
|
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)
|
super().__init__(game_res, resources_dir, game_fps)
|
||||||
|
|
||||||
self._selected_egg = None
|
self._selected_egg = None
|
||||||
@ -25,7 +40,7 @@ class Surface(surface.GameSurface):
|
|||||||
|
|
||||||
def update(self):
|
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()
|
self.preprocess()
|
||||||
|
|
||||||
@ -35,10 +50,8 @@ class Surface(surface.GameSurface):
|
|||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
if event.key == pygame.K_DOWN:
|
if event.key == pygame.K_DOWN:
|
||||||
# Scroll down on the info screen.
|
|
||||||
self._info_text.scroll_down()
|
self._info_text.scroll_down()
|
||||||
if event.key == pygame.K_UP:
|
if event.key == pygame.K_UP:
|
||||||
# Scroll up on the info screen.
|
|
||||||
self._info_text.scroll_up()
|
self._info_text.scroll_up()
|
||||||
if event.key == pygame.K_a:
|
if event.key == pygame.K_a:
|
||||||
self.running = False
|
self.running = False
|
||||||
|
@ -5,22 +5,23 @@ from pocket_friends.elements import surface
|
|||||||
|
|
||||||
class Surface(surface.GameSurface):
|
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):
|
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:
|
Args:
|
||||||
game_res (int): The internal resolution of the game
|
game_res: The internal resolution of the surface.
|
||||||
resources_dir (str): The full path of the game's resource directory
|
resources_dir: The path of the game's main resource directory.
|
||||||
game_fps (int): The
|
game_fps: How many frames per second the game will run at.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
super().__init__(game_res, resources_dir, game_fps)
|
super().__init__(game_res, resources_dir, game_fps)
|
||||||
|
|
||||||
self._frames = 0
|
self._frames = 0 # Counter for the number of frames passed
|
||||||
self._delay = 1
|
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()
|
self._title = pygame.image.load(resources_dir + '/images/title.png').convert_alpha()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user