Package pajammin :: Package entity :: Module entity :: Class Entity
[show private | hide private]
[frames | no frames]

Type Entity

object --+
         |
        Entity

Known Subclasses:
Agent, Decoration, EditorLabel, Ground, LabeledRegion, LevelExit, Mark, PajamaPickup, Platform, Projectile, SolidSpace, Teleporter, Wall

A single object in the game, such as a platform, a monster, the player's avatar, a projectile, or a background decoration. Each type of game level object is defined using a subclass of Entity; and each individual game-level object is represented by a single instance of one of those subclasses.

Each entity has a list of bodies, specifying what space is taken up by that entity. (Most entities have exactly one body, but there are some exceptions.) Each entity also has a list of sprites, defining how the entity should be displayed on-screen.
Method Summary
  __repr__(self)
  add_body(self, body)
  add_sprite(self, sprite)
  after(self, duration, callback, *params, **kwparams)
After the given duration has elapsed, call the given callback function.
  handle_collision(self, obstacle, side)
Called when one of the entity's bodies collides with another body.
  handle_lose_support(self, old_support)
Called when one of the entity's bodies becomes unsupported.
  handle_movement(self, dx, dy)
Called when one of the entity's bodies moves.
  icon(cls)
Return an image that can be used as an icon for this entity class. (Class method)
  remove_body(self, body)
  remove_sprite(self, sprite)
  update(self, duration)
Perform any necessary updates to this entity.
  use(self)
Define this method for entities that the avatar can 'use'.
    Inherited from object
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
Return hash(x)...
  __new__(T, S, ...)
Return a new object with type S, a subtype of T...
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
Return str(x)...

Property Summary
  bodies
  sprites

Instance Variable Summary
bool alive: A flag indicating whether the entity is alive or not.
  bodies = pajammin.entity.entity.Entity.bodies
NoneType level: A pointer to the level that contains this entity (if any).
  sprites = pajammin.entity.entity.Entity.sprites
NoneType update_delay: The amount of time that has elapsed since the last time update was called for this entity.

Class Variable Summary
bool autouse = False
bool is_usable = False
int update_interval: The interval at which entities in a given class should have its update function called.

Instance Method Details

__repr__(self)
(Representation operator)

Overrides:
__builtin__.object.__repr__

add_body(self, body)

add_sprite(self, sprite)

after(self, duration, callback, *params, **kwparams)

After the given duration has elapsed, call the given callback function.
Parameters:
duration - Duration, in msec
callback - The function to call.
params - Parameters to the callback.

handle_collision(self, obstacle, side)

Called when one of the entity's bodies collides with another body. By default, this does nothing.

handle_lose_support(self, old_support)

Called when one of the entity's bodies becomes unsupported. By default, this does nothing.
Parameters:
old_support - The body that used to support this body (or None if the old support was deleted).

handle_movement(self, dx, dy)

Called when one of the entity's bodies moves. By default, this moves all of the entity's sprites.

remove_body(self, body)

remove_sprite(self, sprite)

update(self, duration)

Perform any necessary updates to this entity. By default, this does nothing.
Parameters:
duration - The amount of time that has elapsed since the last time update() was called, in msec.

use(self)

Define this method for entities that the avatar can 'use'. (If you override this, then you should also set is_usable or autouse to true!)

Class Method Details

icon(cls)

Returns:
An image that can be used as an icon for this entity class.

Property Details

bodies

Get Method:
unknown-7673968(...)

sprites

Get Method:
unknown-7673904(...)

Instance Variable Details

alive

A flag indicating whether the entity is alive or not. If this is set to False, then the entity will be removed from the game on the next call to GameEngine.update().
Type:
bool
Value:
True                                                                   

level

A pointer to the level that contains this entity (if any). This is initialized by Level.add_entity(). This pointer can be used to learn about and communicate with other entities in the level.
Type:
NoneType
Value:
None                                                                  

update_delay

The amount of time that has elapsed since the last time update was called for this entity.
Type:
NoneType
Value:
None                                                                  

Class Variable Details

autouse

Type:
bool
Value:
False                                                                  

is_usable

Type:
bool
Value:
False                                                                  

update_interval

The interval at which entities in a given class should have its update function called.
Type:
int
Value:
1000