created new submodule to contain game elements

This commit is contained in:
Nicholas Dyer 2023-05-12 11:44:58 -04:00
parent 65365adc3d
commit b97d54f49d
4 changed files with 14 additions and 4 deletions

View File

@ -0,0 +1 @@
"""Sub-module for use in the game. Helps with the drawing of various objects such as sprites and text boxes."""

View File

@ -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 = []

View File

@ -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

View File

@ -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