Timer#

class miniworlds.tools.timer.Timer(time)[source]#

Base class for timers. Calls act() Method after time frames.

Public Methods:

__init__(time)

tick()

act()

Act method for timer.

Inherited from Timed

__init__()

tick()

unregister()

remove timer from world


act()[source]#

Act method for timer. Called after actual_time frames.

tick()[source]#

ActionTimer#

class miniworlds.tools.timer.ActionTimer(time, method, arguments=None)[source]#

Calls a method after time frames.

Example

Player moves after 48 frames:

miniworlds.ActionTimer(48, player.move, 2)

Same as above with decorator:

@miniworlds.timer(frames = 24)
def moving():
    player.move()

Public Methods:

__init__(time, method[, arguments])

act()

Act method for timer.

Inherited from Timer

__init__(time)

tick()

act()

Act method for timer.

Inherited from Timed

__init__()

tick()

unregister()

remove timer from world

Private Methods:

_call_method()


__init__(time, method, arguments=None)[source]#
Parameters:
  • time (int) – After time frames, the method is called

  • method (callable) – The method to call.

  • arguments ([type], optional) – Arguments for the method.

act()[source]#

Act method for timer. Called after actual_time frames.

LoopActionTimer#

class miniworlds.tools.timer.LoopActionTimer(time, method, arguments=None)[source]#

Calls a method after time frames repeatedly until the timer is unregistered.

Example

Player moves after 48 frames:

miniworlds.LoopTimer(48, player.move, 2)

Same as above with decorator:

@miniworlds.loop(frames = 24)
def moving():
    player.move()

Public Methods:

act()

Act method for timer.

Inherited from ActionTimer

__init__(time, method[, arguments])

act()

Act method for timer.

Inherited from Timer

__init__(time)

tick()

act()

Act method for timer.

Inherited from Timed

__init__()

tick()

unregister()

remove timer from world

Private Methods:

Inherited from ActionTimer

_call_method()


act()[source]#

Act method for timer. Called after actual_time frames.