zacharycarter / zengine

2D | 3D Game development library
157 stars 13 forks source link

Fixup the timer module #35

Closed define-private-public closed 6 years ago

define-private-public commented 6 years ago

As mentioned in a few commit comments and issue #21, the first round of the timer module looked a little wrong (e.g. it was giving us milliseconds for deltaTime() when it should have been giving us seconds instead). This commit fixes that and removes a little cruft.

Under the hood all of the times are measured in hard integers, but the programmer is given a floating point interface to using the time.

On top of that, the timer module now has a Timer object. The rationale for this is two fold:

  1. This makes the Timer less tied into the engine internals (i.e. independant).
  2. Users may need timers for other things (e.g. spell cooldowns, time trials in racing scenarios, making a day n' night cycle; the list goes on). Before we only had one global timer. Now we've got many that the user can use (and resuse).

I've also added some documentation better explaining things. (I should maybe add some drawings too).

closes #21

define-private-public commented 6 years ago

As a note for future planning & features, with this object based Timer, we could add in something so an Event (using the events) module could be triggered after a certain amount of time has been reached.