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.
-
-
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()
.
-
-
class
peng3d.actor.
Controller
(actor)[source]¶ Base class for all controllers.
Controllers define behaviour 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 ofActor.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
-