pygamelib.board_items.BoardComplexItem

class pygamelib.board_items.BoardComplexItem(**kwargs)

New in version 1.2.0.

A BoardComplexItem is the base item for multi cells elements. It inherits from BoardItem and accepts all its parameters.

The main difference is that a complex item can use Sprite as representation.

You can see a complex item as a collection of other items that are ruled by the same laws. They behave as one but a complex item is actually made of complex components. At first it is not important but you may want to exploit that as a feature for your game.

On top of BoardItem the constructor accepts the following parameters:

Parameters:
  • sprite (Sprite) – A sprite representing the item.
  • size (array[int]) – The size of the item. It impact movement and collision detection amongst other things. If it is left empty the Sprite size is used. If no sprite is given to the constructor the default size is 2x2.
  • base_item_type (BoardItemComplexComponent) – the building block of the complex item. The complex item is built from a 2D array of base items.
Null_sprixel:

The null_sprixel is a bit of a special parameter: during construction a null sprixel is replaced by a BoardItemVoid. This is a trick to show the background (i.e transparency). A sprixel can take the color of the background but a complex item with a null_sprixel that correspond to transparent zone of a sprite will really be transparent and show the background.

Null_sprixel:

Sprixel

__init__(**kwargs)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(**kwargs) Initialize self.
can_move() This is a virtual method that must be implemented in deriving classes.
collides_with(other) Tells if this item collides with another item.
column Convenience method to get the current stored column of the item.
debug_info() Return a string with the list of the attributes and their current value.
display() Print the model WITHOUT carriage return.
distance_to(other) Calculates the distance with an item.
height Convenience method to get the height of the item.
inventory_space() This is a virtual method that must be implemented in deriving class.
item(row, column) Return the item at the row, column position if it is within the item’s boundaries.
overlappable() This is a virtual method that must be implemented in deriving class.
pickable() This is a virtual method that must be implemented in deriving class.
position_as_vector() Returns the current item position as a Vector2D
row Convenience method to get the current stored row of the item.
store_position(row, column) Store the BoardItem position for self access.
update_sprite() Update the complex item with the current sprite.
width Convenience method to get the width of the item.