Package horizons :: Module timer :: Class Timer
[hide private]
[frames] | no frames]

Class Timer

source code

util.living.LivingObject --+
                           |
                          Timer

The Timer class manages game-ticks, every tick executes a set of functions in its call lists, this is especially important for multiplayer, to allow synchronous play.

Instance Methods [hide private]
 
__init__(self, tick_next_id=Scheduler.FIRST_TICK_ID, freeze_protection=False)
NOTE: timer will not start until activate() is called
source code
 
activate(self)
Actually starts the timer
source code
 
end(self)
Put all the code the object needs to end safely here.
source code
 
add_test(self, call)
Adds a call to the test list
source code
 
add_call(self, call)
Adds a call to the call list
source code
 
remove_test(self, call)
Removes a call from the test list
source code
 
remove_call(self, call)
Removes a call from the call list
source code
 
get_ticks(self, seconds)
Returns the number of ticks for the specified number of seconds.
source code
 
check_tick(self)
check_tick is called by the engines _pump function to signal a frame idle.
source code
Class Variables [hide private]
  ACCEPTABLE_TICK_DELAY = 0.2
  DEFER_TICK_ON_DELAY_BY = 0.4
Method Details [hide private]

__init__(self, tick_next_id=Scheduler.FIRST_TICK_ID, freeze_protection=False)
(Constructor)

source code 

NOTE: timer will not start until activate() is called

Parameters:
  • tick_next_id - int next tick id
  • freeze_protection - whether to check for tick delay and strech time in case (breaks mp)

end(self)

source code 

Put all the code the object needs to end safely here. Make sure it always contains the super(YOUROBJECT, self).end() call, to ensure all parentobjects are deinited correctly.

Overrides: util.living.LivingObject.end
(inherited documentation)

add_test(self, call)

source code 

Adds a call to the test list

Parameters:
  • call - function function which should be added

add_call(self, call)

source code 

Adds a call to the call list

Parameters:
  • call - function function which should be added

remove_test(self, call)

source code 

Removes a call from the test list

Parameters:
  • call - function function which were added before

remove_call(self, call)

source code 

Removes a call from the call list

Parameters:
  • call - function function which were added before

get_ticks(self, seconds)

source code 

Returns the number of ticks for the specified number of seconds.

Parameters:
  • seconds - number of seconds that are to be converted into ticks
Returns:
int