peng3d.actor - Extendable Actor System

class peng3d.actor.Actor(peng, world, uuid=None, pos=[0, 0, 0])[source]

Actor object, base class for all other Actors in the world.

An actor represents an object in the world, for example the player, an animal, enemy or dropped item.

Everything that is not part of the terrain should be an actor.

The default actor does not do anything, you should look at the subclasses for more information.

addController(controller)[source]

Adds a controller to the actor.

A controller can control its actor and can act as a bridge between actor and user inputs.

Controllers may be added anytime during the lifetime of an actor.

on_move(old)[source]

Fake event handler called if the location of this actor changes.

This handler is called after the location has changed.

Parameters:old (list) – The previous position
pos

Property allowing access to the position of this actor.

This actor is read-write but calls on_move() if it is set.

render(view=None)[source]

Called by World.render3d() to render this actor.

By default, this method calls the draw method of its model, if any.

For custom render behavior, it is recommended to extend this method or modify the model.

setAnimation(animation, transition=None, force=False)[source]

Sets the animation the model of this actor should show.

animation is the name of the animation to switch to.

transition can be used to override the transition between the animations.

force can be used to force reset the animation even if it is already running.

If there is no model set for this actor, a RuntimeError will be raised.

setModel(model)[source]

Sets the model this actor should use when drawing.

This method also automatically initializes the new model and removes the old, if any.

class peng3d.actor.RotatableActor(peng, world, uuid=None, pos=[0, 0, 0], rot=[0, 0])[source]

Actor that can also be rotated.

This subclass adds a rotational value to the actor and a method to move the actor along the current rotation.

move(dist)[source]

Moves the actor using standard trigonometry along the current rotational vector.

Parameters:dist (float) – Distance to move

Todo

Test this method, also with negative distances

on_rotate(old)[source]

Fake event handler called if the rotation of this actor changes.

This handler is called after the rotation has been made.

Parameters:old (tuple) – Old rotation before rotating
rot

Property for accessing the rotation of this actor.

Rotation is a tuple of (x,y) where y is clamped to -90 and 90. x rolls over at 360, resulting in a seamless experience for players.

This property may also be written to, this calls on_rotate().

peng3d.actor.RotateableActor

alias of peng3d.actor.RotatableActor

class peng3d.actor.Controller(actor)[source]

Base class for all controllers.

Controllers define behavior of Actors and can be used to control them via e.g. the keyboard or an AI.

Every controller is bound to its actor and can be enabled and disabled individually. You may also deactivate all controllers of an Actor by setting the enabled key of Actor.controlleroptions to False.

enabled

Property allowing to get and set if this controller should be active.

When getting this property, the result of ANDing the internal flag and the actor flag is returned.

When setting, only the local internal flag is set, allowing other controllers to still work.

Raises:AssertionError – when the supplied value is not of type bool
registerEventHandlers()[source]

Method to be overridden by subclasses for registering event handlers.

Automatically called upon object creation.