updated comments, made some attributes private
This commit is contained in:
parent
4045930bd9
commit
d8775fb1a9
@ -58,10 +58,24 @@ class SpriteSheet:
|
|||||||
|
|
||||||
class SelectionEgg(pygame.sprite.Sprite):
|
class SelectionEgg(pygame.sprite.Sprite):
|
||||||
"""
|
"""
|
||||||
Class for the eggs on the egg selection screen.
|
Sprite to render the egg on the egg selection screen.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
egg_color (str): The color of the egg (also its name).
|
||||||
|
description (str): The description of the egg to be displayed when selected.
|
||||||
|
contentedness (int): How likely the egg is to stay happy, ranges from 0-5.
|
||||||
|
metabolism (int): How quickly the egg will get hungry, ranges from 0-5.
|
||||||
|
rect (pygame.Rect): Pygame rectangle used to position the egg on screen.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, egg_color, resources_dir):
|
def __init__(self, egg_color, resources_dir):
|
||||||
|
"""
|
||||||
|
Creates a SelectionEgg object given an egg color and a resource location.
|
||||||
|
Args:
|
||||||
|
egg_color (str): The color egg that should be rendered.
|
||||||
|
resources_dir (str): The path of the resources directory.
|
||||||
|
"""
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
self.egg_color = egg_color
|
self.egg_color = egg_color
|
||||||
@ -79,20 +93,21 @@ class SelectionEgg(pygame.sprite.Sprite):
|
|||||||
# Load the egg from the given color and get the bounding rectangle for the image.
|
# Load the egg from the given color and get the bounding rectangle for the image.
|
||||||
sprite_sheet = SpriteSheet(resources_dir + '/images/bloops/{0}/egg.png'.format(self.egg_color),
|
sprite_sheet = SpriteSheet(resources_dir + '/images/bloops/{0}/egg.png'.format(self.egg_color),
|
||||||
resources_dir + '/images/bloops/{0}/egg.json'.format(self.egg_color))
|
resources_dir + '/images/bloops/{0}/egg.json'.format(self.egg_color))
|
||||||
self.images = sprite_sheet.images
|
self._images = sprite_sheet.images
|
||||||
|
|
||||||
# Get the rectangle from the first image in the list
|
# Get the rectangle from the first image in the list
|
||||||
self.rect = self.images[0].get_rect()
|
self.rect = self._images[0].get_rect()
|
||||||
self.index = 0
|
print(type(self.rect))
|
||||||
self.image = self.images[self.index]
|
self._index = 0
|
||||||
|
self.image = self._images[self._index]
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""
|
"""
|
||||||
Updates the sprite object.
|
Update the sprite to the next animation frame.
|
||||||
"""
|
"""
|
||||||
# Animate the sprite
|
# Animate the sprite
|
||||||
self.index = (self.index + 1) % len(self.images)
|
self._index = (self._index + 1) % len(self._images)
|
||||||
self.image = self.images[self.index]
|
self.image = self._images[self._index]
|
||||||
|
|
||||||
|
|
||||||
class InfoText:
|
class InfoText:
|
||||||
|
Loading…
Reference in New Issue
Block a user