pygamelib.board_items.BoardItem

class pygamelib.board_items.BoardItem(**kwargs)

Base class for any item that will be placed on a Board.

Parameters:
  • type (str) – A type you want to give your item. It can be any string. You can then use the type for sorting or grouping for example.
  • name (str) – A name for this item. For identification purpose.
  • pos (array) – the position of this item. When the item is managed by the Board and Game engine this member hold the last updated position of the item. It is not updated if you manually move the item. It must be an array of 2 integers [row,column]
  • model (str) – The model to use to display this item on the Board. Be mindful of the space it will require. Default value is ‘*’.
  • parent – The parent object of the board item. Usually a Board or Game object.

Important

Starting with version 1.2.0 and introduction of complex items, BoardItems have a size. That size CANNOT be set. It is always 1x1. This is because a BoardItem always takes 1 cell, regardless of its actual number of characters. Python does not really provide a way to prevent changing that member but if you do, you’ll break rendering. You have been warned.

__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.
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.
width Convenience method to get the width of the item.