From b97d54f49d153895f50b1ee527c42d991ee9040d Mon Sep 17 00:00:00 2001 From: Nicholas Dyer Date: Fri, 12 May 2023 11:44:58 -0400 Subject: [PATCH] created new submodule to contain game elements --- pocket_friends/game_files/elements/__init__.py | 1 + .../game_files/{surfaces => elements}/sprites.py | 12 +++++++++++- pocket_friends/game_files/surfaces/egg_select.py | 2 +- pocket_friends/game_files/surfaces/selection_info.py | 3 +-- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 pocket_friends/game_files/elements/__init__.py rename pocket_friends/game_files/{surfaces => elements}/sprites.py (94%) diff --git a/pocket_friends/game_files/elements/__init__.py b/pocket_friends/game_files/elements/__init__.py new file mode 100644 index 0000000..6867307 --- /dev/null +++ b/pocket_friends/game_files/elements/__init__.py @@ -0,0 +1 @@ +"""Sub-module for use in the game. Helps with the drawing of various objects such as sprites and text boxes.""" diff --git a/pocket_friends/game_files/surfaces/sprites.py b/pocket_friends/game_files/elements/sprites.py similarity index 94% rename from pocket_friends/game_files/surfaces/sprites.py rename to pocket_friends/game_files/elements/sprites.py index 0c1e8d8..6f0bb8e 100644 --- a/pocket_friends/game_files/surfaces/sprites.py +++ b/pocket_friends/game_files/elements/sprites.py @@ -4,10 +4,20 @@ import json class SpriteSheet: """ - Imports a sprite sheet as separate pygame images given an image file and a json file. + Class to be used by sprites in order to give them a texture and an animation. + + Attributes: + images (list) List of all the sprites in the animation separated from the sprite sheet. """ def __init__(self, sprite_sheet, texture_json): + """ + Creates a sprite sheet given a sprite image and its corresponding JSON file. + Args: + sprite_sheet (str): The path of the sprite sheet image component. + texture_json (str): The path of the sprite sheet JSON component, contains the number of frames in the + sprite sheet, and the width and height of an individual sprite from the sprite sheet. + """ # Load in whole sprite sheet as one image. self.sprite_sheet = pygame.image.load(sprite_sheet).convert_alpha() self.images = [] diff --git a/pocket_friends/game_files/surfaces/egg_select.py b/pocket_friends/game_files/surfaces/egg_select.py index 7a97d90..4ae54d1 100644 --- a/pocket_friends/game_files/surfaces/egg_select.py +++ b/pocket_friends/game_files/surfaces/egg_select.py @@ -1,5 +1,5 @@ import pygame -from . import sprites +from ..elements import sprites import pocket_friends.game_files.io.gpio_handler as gpio_handler from ..io.input_handler import InputHandler diff --git a/pocket_friends/game_files/surfaces/selection_info.py b/pocket_friends/game_files/surfaces/selection_info.py index 8b8aeac..94df328 100644 --- a/pocket_friends/game_files/surfaces/selection_info.py +++ b/pocket_friends/game_files/surfaces/selection_info.py @@ -1,7 +1,6 @@ import pygame -from . import sprites +from ..elements import sprites import pocket_friends.game_files.io.gpio_handler as gpio_handler -from .sprites import SelectionEgg from ..io.input_handler import InputHandler