Actuator

class pygamelib.actuators.Actuator(parent)

Bases: object

Actuator is the base class for all Actuators. It is mainly a contract class with some utility methods.

By default, all actuators are considered movement actuators. So the base class only require next_move() to be implemented.

Parameters:parent – the item parent.
__init__(parent)

The constructor take only one (positional) parameter: the parent object.

Important

The default state of ALL actuators is RUNNING. If you want your actuator to be in a different state (PAUSED for example), you have to do it yourself.

Methods

__init__(parent) The constructor take only one (positional) parameter: the parent object.
load(data) Load serialized data, create and returns a new actuator out of these data.
next_move() That method needs to be implemented by all actuators or a NotImplementedError exception will be raised.
pause() Set the actuator state to PAUSED.
serialize() Serializes the actuator and returns it as a dict.
start() Set the actuator state to RUNNING.
stop() Set the actuator state to STOPPED.
load(data: dict = None)

Load serialized data, create and returns a new actuator out of these data.

That method needs to be implemented by all actuators or a NotImplementedError exception will be raised.

Raises:NotImplementedError
next_move()

That method needs to be implemented by all actuators or a NotImplementedError exception will be raised.

Raises:NotImplementedError
pause()

Set the actuator state to PAUSED.

Example:

mygame.pause()
serialize()

Serializes the actuator and returns it as a dict.

That method needs to be implemented by all actuators or a NotImplementedError exception will be raised.

Raises:NotImplementedError
start()

Set the actuator state to RUNNING.

If the actuator state is not RUNNING, actuators’ next_move() function (and all derivatives) should not return anything.

Example:

mygame.start()
stop()

Set the actuator state to STOPPED.

Example:

mygame.stop()