class documentation

class Entity(engine.Entity):

View In Hierarchy

Represent a game entity with sprites, callbacks, and gameplay state.

Methods

  • has_3d_sprite()
    Return whether the entity has a 3D sprite.
  • set_3d_sprite_rotation(rotation)
    Set the 3D sprite rotation.
  • set_3d_sprite_scale(scale)
    Set the 3D sprite scale.
  • update_3d_sprite_position()
    Synchronize the 3D sprite position.
  • has_changed_position()
    Return whether the position changed.
  • set_name(name)
    Set the entity name.
  • set_type(type)
    Set the entity type.
  • set_position(position)
    Set the entity position.
  • position_set(x, y, z, integer)
    Set the entity position with optional z and integer component.
  • set_old_position(old_position)
    Set the previous entity position.
  • set_size(size)
    Set the entity size.
  • set_is_8bit(is_8bit)
    Set the 8-bit graphics flag.
  • set_is_active(is_active)
    Set the active flag.
  • set_is_visible(is_visible)
    Set the visible flag.
  • set_is_player(is_player)
    Set the player flag.
  • set_direction(direction)
    Set the facing direction.
  • direction_set(x, y, z, integer)
    Set the facing direction with optional z and integer component.
  • set_plane(plane)
    Set the camera plane.
  • plane_set(x, y, z, integer)
    Set the camera plane with optional z and integer component.
  • set_state(state)
    Set the gameplay state.
  • set_start_position(start_position)
    Set the movement start position.
  • set_end_position(end_position)
    Set the movement end position.
  • set_move_timer(move_timer)
    Set the movement duration.
  • set_elapsed_move_timer(elapsed_move_timer)
    Set the elapsed movement time.
  • set_radius(radius)
    Set the collision radius.
  • set_speed(speed)
    Set the movement speed.
  • set_attack_timer(attack_timer)
    Set the attack cooldown duration.
  • set_elapsed_attack_timer(elapsed_attack_timer)
    Set the elapsed attack time.
  • set_strength(strength)
    Set the entity strength.
  • set_health(health)
    Set the current health.
  • set_max_health(max_health)
    Set the maximum health.
  • set_level(level)
    Set the entity level.
  • set_xp(xp)
    Set the experience points.
  • set_health_regen(health_regen)
    Set the health regeneration rate.
  • set_elapsed_health_regen(elapsed_health_regen)
    Set the elapsed regeneration time.
  • set_sprite_rotation(sprite_rotation)
    Set the 3D sprite rotation.
  • set_sprite_scale(sprite_scale)
    Set the 3D sprite scale.
  • set_sprite3d_type(type)
    Set the 3D sprite type.
  • set_sprite3d(sprite3d)
    Set the native 3D sprite reference.
  • set_sprite(sprite)
    Set the main 2D sprite.
  • set_sprite_left(sprite_left)
    Set the left-facing 2D sprite.
  • set_sprite_right(sprite_right)
    Set the right-facing 2D sprite.
  • __del__()
    Release the native entity resources.
Parameters
nameEntity name.
typeEntity type constant.
positionInitial entity position.
sizeEntity size used for rendering and collision checks.
sprite_dataMain 2D sprite. Defaults to None.
sprite_leftSprite used when facing left. Defaults to None.
sprite_rightSprite used when facing right. Defaults to None.
startCallback invoked when the entity starts. Defaults to None.
stopCallback invoked when the entity stops. Defaults to None.
updateCallback invoked during entity updates. Defaults to None.
renderCallback invoked during entity rendering. Defaults to None.
collisionCallback invoked after a collision. Defaults to None.
is_8bit_spriteWhether the entity uses 8-bit graphics. Defaults to False.
sprite_3d_typeInitial 3D sprite type. Defaults to SPRITE_3D_NONE.
sprite_3d_colorInitial 3D sprite color. Defaults to 0x0000.
Method __setattr__ Set an entity attribute, routing to the matching setter.
Instance Variable attack_timer Attack cooldown duration. Writable.
Instance Variable direction Entity facing direction. Writable.
Instance Variable elapsed_attack_timer Time since the last attack. Writable.
Instance Variable elapsed_health_regen Time since the last health regeneration. Writable.
Instance Variable elapsed_move_timer Elapsed movement time. Writable.
Instance Variable end_position Movement end position. Writable.
Instance Variable ENTITY_3D_SPRITE 3D sprite entity type.
Instance Variable ENTITY_ATTACKED Attacked entity state.
Instance Variable ENTITY_ATTACKING Attacking entity state.
Instance Variable ENTITY_DEAD Dead entity state.
Instance Variable ENTITY_ENEMY Enemy entity type.
Instance Variable ENTITY_ICON Icon entity type.
Instance Variable ENTITY_IDLE Idle entity state.
Instance Variable ENTITY_MOVING Moving entity state.
Instance Variable ENTITY_MOVING_TO_END Moving-to-end entity state.
Instance Variable ENTITY_MOVING_TO_START Moving-to-start entity state.
Instance Variable ENTITY_NPC Non-player character entity type.
Instance Variable ENTITY_PLAYER Player entity type.
Instance Variable health Current health. Writable.
Instance Variable health_regen Health regeneration rate. Writable.
Instance Variable is_8bit Whether the entity uses 8-bit graphics. Writable.
Instance Variable is_active Whether the entity participates in updates. Writable.
Instance Variable is_player Whether the entity is the player. Writable.
Instance Variable is_visible Whether the entity is rendered. Writable.
Instance Variable level Entity level. Writable.
Instance Variable max_health Maximum health. Writable.
Instance Variable move_timer Movement duration. Writable.
Instance Variable name Entity name. Writable.
Instance Variable old_position Previous entity position. Writable.
Instance Variable plane Entity camera plane. Writable.
Instance Variable position Current entity position. Writable.
Instance Variable radius Collision radius. Writable.
Instance Variable size Entity size. Writable.
Instance Variable speed Movement speed. Writable.
Instance Variable sprite Main 2D sprite. Writable.
Instance Variable sprite_3d Native 3D sprite reference. Writable.
Instance Variable SPRITE_3D_CUSTOM Custom 3D sprite.
Instance Variable SPRITE_3D_HOUSE House 3D sprite.
Instance Variable SPRITE_3D_HUMANOID Humanoid 3D sprite.
Instance Variable SPRITE_3D_NONE No 3D sprite.
Instance Variable SPRITE_3D_PILLAR Pillar 3D sprite.
Instance Variable SPRITE_3D_TREE Tree 3D sprite.
Instance Variable sprite_3d_type 3D sprite type. Writable.
Instance Variable sprite_left Left-facing 2D sprite. Writable.
Instance Variable sprite_right Right-facing 2D sprite. Writable.
Instance Variable sprite_rotation 3D sprite rotation. Writable.
Instance Variable sprite_scale 3D sprite scale. Writable.
Instance Variable start_position Movement start position. Writable.
Instance Variable state Current gameplay state. Writable.
Instance Variable strength Damage dealt by the entity. Writable.
Instance Variable type Entity type constant. Writable.
Instance Variable xp Experience points. Writable.
def __setattr__(self, name, value):

Set an entity attribute, routing to the matching setter.

Parameters
name:strAttribute name to set.
value:objectNew value for the attribute.
attack_timer: float =

Attack cooldown duration. Writable.

direction: Vector =

Entity facing direction. Writable.

elapsed_attack_timer: float =

Time since the last attack. Writable.

elapsed_health_regen: float =

Time since the last health regeneration. Writable.

elapsed_move_timer: float =

Elapsed movement time. Writable.

end_position: Vector =

Movement end position. Writable.

ENTITY_3D_SPRITE: int =

3D sprite entity type.

ENTITY_ATTACKED: int =

Attacked entity state.

ENTITY_ATTACKING: int =

Attacking entity state.

ENTITY_DEAD: int =

Dead entity state.

ENTITY_ENEMY: int =

Enemy entity type.

ENTITY_ICON: int =

Icon entity type.

ENTITY_IDLE: int =

Idle entity state.

ENTITY_MOVING: int =

Moving entity state.

ENTITY_MOVING_TO_END: int =

Moving-to-end entity state.

ENTITY_MOVING_TO_START: int =

Moving-to-start entity state.

ENTITY_NPC: int =

Non-player character entity type.

ENTITY_PLAYER: int =

Player entity type.

health: float =

Current health. Writable.

health_regen: float =

Health regeneration rate. Writable.

is_8bit: bool =

Whether the entity uses 8-bit graphics. Writable.

is_active: bool =

Whether the entity participates in updates. Writable.

is_player: bool =

Whether the entity is the player. Writable.

is_visible: bool =

Whether the entity is rendered. Writable.

level: float =

Entity level. Writable.

max_health: float =

Maximum health. Writable.

move_timer: float =

Movement duration. Writable.

name: str =

Entity name. Writable.

old_position: Vector =

Previous entity position. Writable.

plane: Vector =

Entity camera plane. Writable.

position: Vector =

Current entity position. Writable.

radius: float =

Collision radius. Writable.

size: Vector =

Entity size. Writable.

speed: float =

Movement speed. Writable.

sprite: Image or None =

Main 2D sprite. Writable.

sprite_3d: Sprite3D =

Native 3D sprite reference. Writable.

SPRITE_3D_CUSTOM: int =

Custom 3D sprite.

SPRITE_3D_HOUSE: int =

House 3D sprite.

SPRITE_3D_HUMANOID: int =

Humanoid 3D sprite.

SPRITE_3D_NONE: int =

No 3D sprite.

SPRITE_3D_PILLAR: int =

Pillar 3D sprite.

SPRITE_3D_TREE: int =

Tree 3D sprite.

sprite_3d_type: int =

3D sprite type. Writable.

sprite_left: Image or None =

Left-facing 2D sprite. Writable.

sprite_right: Image or None =

Right-facing 2D sprite. Writable.

sprite_rotation: float =

3D sprite rotation. Writable.

sprite_scale: float =

3D sprite scale. Writable.

start_position: Vector =

Movement start position. Writable.

state: int =

Current gameplay state. Writable.

strength: float =

Damage dealt by the entity. Writable.

type: int =

Entity type constant. Writable.

xp: float =

Experience points. Writable.