Package pajammin :: Package entity :: Package agent :: Module avatar :: Class Avatar
[show private | hide private]
[frames | no frames]

Type Avatar

object --+        
         |        
    Entity --+    
             |    
         Agent --+
                 |
                Avatar

Known Subclasses:
Iso3dAvatar

The main character's avatar. At any given time, the avatar wears two PajamaPieces: one pajama shirt and one pajama pants. These pajamas can be activated to perform special abilities.

The avatar's image is composed of 3 sprites: one for the head; one for the torso (that changes when the avatar puts on a new pajama shirt); and one for the legs (that changes when the avatar puts on a new pajama pants).
Method Summary
  __init__(self, x, y)
Create a new agent at the given position.
  climb(self, direction)
  fly(self, direction)
  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.
  icon(cls)
(Class method)
  jump(self, jump_speed)
  play_animation(self, basename, speed)
Change the agent's sprite to display the animation with the given basename, for the duration of the animation (just one time through, if the animation normally loops).
  press_down(self)
  press_left(self)
  press_pjpants(self)
  press_pjshirt(self)
  press_right(self)
  press_up(self)
  release_down(self)
  release_left(self)
  release_pjpants(self)
  release_pjshirt(self)
  release_right(self)
  release_up(self)
  start_climbing(self, surface)
  start_flying(self)
  stop(self, direction)
  stop_climbing(self)
  stop_flying(self)
  update(self, duration)
Update the current state of this agent.
  update_animation(self)
Update the animation mode and speed of this agent's sprite(s), based on the agent's state.
  usable_entity(self)
  walk(self, direction)
  wear(self, pajama)
    Inherited from Agent
  add_effect(self, effect)
Apply a temporary change to the "fixed" properties of this agent.
  attack(self, attack_type, **attack_args)
  current_animation(self)
Return a tuple (basename, speed), indicating the animation name and the animation speed that should be used by this agent's sprite, based on the agent's current state.
  die(self)
Cause the agent to die.
  heal(self, health)
Increase the health of this agent by the given amount.
  hurt(self, damage, damage_type)
Cause the given amount of damage to this agent.
  is_hostile(self, agent)
Return true if this agent is hostile to the given agent.
  register(cls)
(Class method)
  remove_effect(self, *effects_to_remove)
Cancel one or more temporary changes to the "fixed" properties of this agent.
  say(self, text, duration)
Say something...
    Inherited from Entity
  __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_movement(self, dx, dy)
Called when one of the entity's bodies moves.
  remove_body(self, body)
  remove_sprite(self, sprite)
  use(self)
Define this method for entities that the avatar can 'use'.
    Inherited from object
  __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
  is_standing: Is the agent currently standing on something (i.e., supported)?
    Inherited from Agent
  bottom: The y coordinate of the bottom side of the agent's body.
  center: The (x,y) position of the center of the agent's body.
  left: The x coordinate of the left side of the agent's body.
  right: The x coordinate of the right side of the agent's body.
  top: The y coordinate of the top side of the agent's body.
  x: The x coordinate of the center of the agent's body.
  y: The y coordinate of the center of the agent's body.
    Inherited from Entity
  bodies
  sprites

Instance Variable Summary
str faction: The name of the faction that this agent belongs to.
  head_sprite: A sprite for the avatar's head
int health_max: The maximum number of health points this agent can have.
int health_regen: The rate at which this agent regains its health, in HP/sec.
  is_climbing: Are we climbing? (affects input)
  is_flying: Are we flying? (affects input)
  legs_sprite: A sprite for the avatar's legs
int mana_max: The maximum number of mana points this agent can have.
int mana_regen: The rate at which this agent regains its mana, in MP/sec.
  pajamas: What pajamas dow we own?
  pjpants: Our pajama pants
  pjshirt: Our pajama shirt
  torso_sprite: A sprite for the avatar's torso
    Inherited from Agent
  attack_cooldown_timer: ...
int attack_speed: A modifier for the rate at which this agent can attack.
  body: The agent's body.
  effects: A list of the Effects (temporary changes to fixed properties) that are currently affecting this agent.
  facing: The direction that the agent is currently facing.
  health: The number of health points this agent currently has.
bool is_mortal: Determines whether this agent dies when its health reaches zero.
  mana: The number of mana points this agent currently has.
dict resists: A dictionary describing the base amount that this agent resists each damage type.
    Inherited from Entity
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
dict attack_types: A dictionary describing the types of attack that agents in this class can make.
NoneType bbox_size: The default size of the bounding box for agents in this class.
int climb_speed = 100                                                                   
tuple flight_speed = (80, 100)
int jump_speed = 300                                                                   
int update_interval: The interval at which entities in a given class should have its update function called.
int walk_speed = 150                                                                   
    Inherited from Agent
list classes = [<class 'pajammin.entity.agent.flyer.WhiteBird...
int solid_sides: The sides of the agent's body which should be solid for agents in this class.
NoneType sprite_category: The sprite category that should be used to create this agent's sprite.
    Inherited from Entity
bool autouse = False
bool is_usable = False

Instance Method Details

__init__(self, x, y)
(Constructor)

Create a new agent at the given position. The new agent's health and mana will be set to their maximum; and the direction it is facing will be randomly chosen between LEFT and RIGHT.
Overrides:
pajammin.entity.agent.agent.Agent.__init__ (inherited documentation)

climb(self, direction)

fly(self, direction)

handle_collision(self, obstacle, side)

Called when one of the entity's bodies collides with another body. By default, this does nothing.
Overrides:
pajammin.entity.entity.Entity.handle_collision (inherited documentation)

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).
Overrides:
pajammin.entity.entity.Entity.handle_lose_support (inherited documentation)

jump(self, jump_speed=None)

play_animation(self, basename, speed=1)

Change the agent's sprite to display the animation with the given basename, for the duration of the animation (just one time through, if the animation normally loops). The actual animation name will be formed by combining basename with a suffix indicating which direction the agent is facing, such as '_left' or '_down'. Once the specified animation is complete, the agent will resume using current_animation() to decide which animation to display.
Overrides:
pajammin.entity.agent.agent.Agent.play_animation (inherited documentation)

press_down(self)

press_left(self)

press_pjpants(self)

press_pjshirt(self)

press_right(self)

press_up(self)

release_down(self)

release_left(self)

release_pjpants(self)

release_pjshirt(self)

release_right(self)

release_up(self)

start_climbing(self, surface)

start_flying(self)

stop(self, direction=None)

stop_climbing(self)

stop_flying(self)

update(self, duration)

Update the current state of this agent. This update function applies health & mana regeneration, and checks whether the agent's health or mana is at or below zero (taking appropriate actions if either is).
Overrides:
pajammin.entity.agent.agent.Agent.update (inherited documentation)

update_animation(self)

Update the animation mode and speed of this agent's sprite(s), based on the agent's state. This method should be called any time the agent is modified in such a way that its animation mode or speed might need to change.

update_animation() uses current_animation() to decide which of the sprite's animations to display. The method play_animation() can also be used to temporarily override which animation is displayed.
Overrides:
pajammin.entity.agent.agent.Agent.update_animation (inherited documentation)

usable_entity(self)

walk(self, direction)

wear(self, pajama)


Class Method Details

icon(cls)

Overrides:
__builtin__.type.icon

Property Details

is_standing

Is the agent currently standing on something (i.e., supported)?
Get Method:
unknown-17656112(...)

Instance Variable Details

faction

The name of the faction that this agent belongs to. Can be 'goodguy', 'badguy', or 'neutral'.
Type:
str
Value:
'goodguy'                                                              

head_sprite

A sprite for the avatar's head

health_max

The maximum number of health points this agent can have.
Type:
int
Value:
100                                                                   

health_regen

The rate at which this agent regains its health, in HP/sec. This rate may be negative, to indicate a health drain.
Type:
int
Value:
1                                                                     

is_climbing

Are we climbing? (affects input)

is_flying

Are we flying? (affects input)

legs_sprite

A sprite for the avatar's legs

mana_max

The maximum number of mana points this agent can have.
Type:
int
Value:
100                                                                   

mana_regen

The rate at which this agent regains its mana, in MP/sec. This rate may be negative, to indicate a mana drain.
Type:
int
Value:
20                                                                    

pajamas

What pajamas dow we own?

pjpants

Our pajama pants

pjshirt

Our pajama shirt

torso_sprite

A sprite for the avatar's torso

Class Variable Details

attack_types

A dictionary describing the types of attack that agents in this class can make. It maps from attack names to AttackType objects. [xx] should this be considered a fixed property? if so, then a spell or other effect could grant a new attack type to an agent; but it would have to be pretty specific... the agent's sprite would have to have the appropriate animations.
Type:
dict
Value:
{'fireball': <pajammin.entity.agent.agent.ProjectileAttack object at 0\
x107d410>,
 'kick': <pajammin.entity.agent.agent.MeleeAttack object at 0x107d3d0>\
,
 'punch': <pajammin.entity.agent.agent.MeleeAttack object at 0x107d330\
>,
 'starspray': <pajammin.entity.agent.agent.SprayAttack object at 0x107\
d490>,
...                                                                    

bbox_size

The default size of the bounding box for agents in this class.
Type:
NoneType
Value:
(6, 56)                                                                

climb_speed

Type:
int
Value:
100                                                                   

flight_speed

Type:
tuple
Value:
(80, 100)                                                              

jump_speed

Type:
int
Value:
300                                                                   

update_interval

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

walk_speed

Type:
int
Value:
150