mutable
Classes for things in the skool that change appearance depending on their
state. For example, a cup that may be empty or contain water or sherry.
-
class mutable.Bike(x, y)
Represents the portion of the tree that may or may not have a bike
chained to it.
Parameters: |
- x – The x-coordinate of the bike-on-a-tree image.
- y – The y-coordinate of the bike-on-a-tree image.
|
-
chain()
- Return a 3-tuple containing a list of the images to use when the
bike is chained to the tree, and the x- and y-coordinates of the
images.
-
set_images(unchained_images, chained_images)
Define the images to use for the bike-on-a-tree.
Parameters: |
- unchained_images – A list of images to use when the bike is not
chained to the tree.
- chained_images – A list of images to use when the bike is chained
to the tree.
|
-
unchain()
- Return a 3-tuple containing a list of the images to use when the
bike is not chained to the tree, and the x- and y-coordinates of the
images.
-
class mutable.Cup(cup_id, coords, water_id, sherry_id)
A cup that may be empty or filled with water or sherry.
Parameters: |
- cup_id – The ID of the cup.
- coords – The coordinates of the cup.
- water_id – The ID of the liquid for which the water-filled image
should be used.
- sherry_id – The ID of the liquid for which the sherry-filled image
should be used.
|
-
fill(contents)
Fill the cup with a liquid, or empty it.
Parameter: | contents – The liquid to fill the cup with, or None to empty
it. |
-
insert_frog(frog)
Insert a frog into the cup.
Parameter: | frog (Frog) – The frog. |
-
is_empty()
- Return whether the cup is empty (contains no liquid or frogs).
-
remove_frog(frog)
Remove a frog from the cup.
Parameter: | frog (Frog) – The frog. |
-
set_images(empty_images, water_images, sherry_images)
Define the images to use for the cup.
Parameters: |
- empty_images – A list of images of the cup when empty.
- water_images – A list of images of the cup when filled with
water.
- sherry_images – A list of images of the cup when filled with
sherry.
|
-
class mutable.Flashable(x, y, image=None, inverse_image=None, score=0)
Abstract superclass for objects that flash (shields and the safe).
Parameters: |
- x – The x-coordinate of the object.
- y – The y-coordinate of the object.
- image (pygame.Surface) – The normal image of the object.
- inverse_image (pygame.Surface) – The inverse image of the object.
- score – The points awarded for hitting the object.
|
-
flash()
- Mark the object as flashing.
-
get_images(inverse)
If the object is flashing, return a 3-tuple containing the x- and
y-coordinates of the object, and an image of it. Otherwise return
(0, 0, None) (so that the object is not drawn).
Parameter: | inverse – If True, return the inverse image; otherwise return
the normal image. |
-
unflash()
- Mark the object as not flashing.
-
class mutable.Safe(x, y, image=None, inverse_image=None, score=0)
- A safe that will flash or unflash when hit.
-
class mutable.Shield(x, y, image=None, inverse_image=None, score=0)
- A shield that will flash or unflash when hit.