pygamelib.board_items.Tile

class pygamelib.board_items.Tile(**kwargs)

New in version 1.2.0.

A Tile is a standard BoardComplexItem configured by default to:

  • be overlappable
  • be not pickable
  • be immovable.

Aside from the movable attributes (it inherit from GenericStructure so it’s an Immovable object), everything else is configurable.

It is particularly useful to display a Sprite on the background or to create terrain.

Parameters:
  • overlappable (bool) – Defines if the Tile can be overlapped.
  • restorable (bool) – Defines is the Tile should be restored after being overlapped.
  • pickable (bool) – Defines if the Tile can be picked up by the Player or NPC.

Please see BoardComplexItem for additional parameters.

Example:

grass_sprite = Sprite.load_from_ansi_file('textures/grass.ans')
for pos in grass_positions:
    outdoor_level.place_item( Tile(sprite=grass_sprite), pos[0], pos[1] )
__init__(**kwargs)

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

Methods

__init__(**kwargs) Initialize self.
can_move() A Tile cannot move.
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() Return the size of the Immovable Item for the Inventory.
item(row, column) Return the item at the row, column position if it is within the item’s boundaries.
overlappable() This represent the capacity for a BoardItem to be overlapped by player or NPC.
pickable() This represent the capacity for a BoardItem to be picked-up by player or NPC.
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.