pygamelib.board_items.NPC

class pygamelib.board_items.NPC(**kwargs)

A class that represent a non playable character controlled by the computer. For the NPC to be successfully managed by the Game, you need to set an actuator.

None of the parameters are mandatory, however it is advised to make good use of some of them (like type or name) for game design purpose.

In addition to its own member variables, this class inherits all members from:

This class sets a couple of variables to default values:

  • max_hp: 10
  • hp: 10
  • remaining_lives: 1
  • attack_power: 5
  • movement_speed: 0.25 (one movement every 0.25 second). Only useful if the game
    mode is set to MODE_RT.
Parameters:actuator (pygamelib.actuators.Actuator) – An actuator, it can be any class but it need to implement pygamelib.actuators.Actuator.

Example:

mynpc = NPC(name='Idiot McStupid', type='dumb_enemy')
mynpc.step = 1
mynpc.actuator = RandomActuator()
__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() Define if the NPC has an inventory.
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() Define if the NPC is overlappable.
pickable() Define if the NPC is pickable.
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.