pygamelib.board_items.Movable

class pygamelib.board_items.Movable(**kwargs)

A class representing BoardItem capable of movements.

Movable subclasses BoardItem.

Parameters:
  • step (int) – the amount of cell a movable can cross in one turn. Default value: 1.
  • step_vertical (int) – the amount of cell a movable can vertically cross in one turn. Default value: step value.
  • step_horizontal (int) – the amount of cell a movable can horizontally cross in one turn. Default value: step value.
  • movement_speed (int|float) – The time (in seconds) between 2 movements of a Movable. It is used by all the Game’s actuation methods to enforce move speed of NPC and projectiles.

The movement_speed parameter is only used when the Game is configured with MODE_RT. Additionally the dtmove property is used to accumulate time between frames. It is entirely managed by the Game object and most of the time you shouldn’t mess up with it. Unless you want to manage movements by yourself. If so, have fun! That’s the point of the pygamelib to let you do whatever you like.

This class derive BoardItem and describe an object that can move or be moved (like a player or NPC). Thus this class implements BoardItem.can_move(). However it does not implement BoardItem.pickable() or BoardItem.overlappable()

__init__(**kwargs)

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

Methods

__init__(**kwargs) Initialize self.
can_move() Movable implements can_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.
has_inventory() This is a virtual method that must be implemented in deriving class.
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.