particles

class pygamelib.gfx.particles.BaseParticle(**kwargs)

Bases: pygamelib.board_items.Movable

Particles are not ready. This is only an early early test. you should not use it. If you do, don’t complain. And if you really want to help, interact on Github or Discord. Thank you ;)

can_move()

Movable implements can_move().

Returns:True
Return type:Boolean
collides_with(other)

Tells if this item collides with another item.

Parameters:other (BoardItem) – The item you want to check for collision.
Return type:bool

Example:

if projectile.collides_with(game.player):
    game.player.hp -= 5
column

Convenience method to get the current stored column of the item.

This is absolutely equivalent to access to item.pos[1].

Returns:The column coordinate
Return type:int

Example:

if item.column != item.pos[1]:
    print('Something extremely unlikely just happened...')
debug_info()

Return a string with the list of the attributes and their current value.

Return type:str
direction()
display()

Print the model WITHOUT carriage return.

distance_to(other)

Calculates the distance with an item.

Parameters:other (BoardItem) – The item you want to calculate the distance to.
Returns:The distance between this item and the other.
Return type:float

Example:

if npc.distance_to(game.player) <= 2.0:
    npc.seek_and_destroy = True
dtmove
has_inventory()

This is a virtual method that must be implemented in deriving class. This method has to return True or False. This represent the capacity for a Movable to have an inventory.

height

Convenience method to get the height of the item.

This is absolutely equivalent to access to item.size[1].

Returns:The height
Return type:int

Example:

if item.height > board.height:
    print('The item is too big for the board.')
inventory_space()

This is a virtual method that must be implemented in deriving class. This method has to return an integer. This represent the size of the BoardItem for the Inventory. It is used for example to evaluate the space taken in the inventory.

Important

That abstract function was called size() before version 1.2.0. As it was exclusively used for inventory space management, it as been renamed. Particularly because now items do have a need for a size.

overlappable()

Overlapable always return true. As by definition a particle is overlapable.

pickable()

A particle is not pickable by default. So that method returns False.

position_as_vector()

Returns the current item position as a Vector2D

Returns:The position as a 2D vector
Return type:Vector2D

Example:

gravity = Vector2D(9.81, 0)
next_position = item.position_as_vector() + gravity.unit()
row

Convenience method to get the current stored row of the item.

This is absolutely equivalent to access to item.pos[0].

Returns:The row coordinate
Return type:int

Example:

if item.row != item.pos[0]:
    print('Something extremely unlikely just happened...')
store_position(row, column)

Store the BoardItem position for self access.

The stored position is used for consistency and quick access to the self postion. It is a redundant information and might not be synchronized.

Parameters:
  • row (int) – the row of the item in the Board.
  • column (int) – the column of the item in the Board.

Example:

item.store_position(3,4)
width

Convenience method to get the width of the item.

This is absolutely equivalent to access to item.size[0].

Returns:The width
Return type:int

Example:

if item.width > board.width:
    print('The item is too big for the board.')