pygamelib.actuators.PatrolActuator

class pygamelib.actuators.PatrolActuator(path=None, parent=None)

The patrol actuator is a subclass of PathActuator. The move inside the function next_move depends on path and index and the mode. Once it reaches the end of the move list it will start cycling back to the beggining of the list. Once it reaches the beggining it will start moving forwards If the state is not running it returns None otherwise it increments the index & then, further compares the index with length of the path. If they both are same then, index is set to value zero and the move is returned back.

Parameters:path (list) – A list of directions.
__init__(path=None, parent=None)

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__([path, parent]) The constructor take only one (positional) parameter: the parent object.
next_move() Return the movement based on current index
pause() Set the actuator state to PAUSED.
set_path(path) Defines a new path
start() Set the actuator state to RUNNING.
stop() Set the actuator state to STOPPED.