Tick indicates a new tick/frame has occurred.
()
| 49 | |
| 50 | // Tick indicates a new tick/frame has occurred. |
| 51 | func (c *Clock) Tick() { |
| 52 | currStamp := theTimer.Now() |
| 53 | |
| 54 | c.counter++ |
| 55 | |
| 56 | c.deltaStamp = currStamp - c.frameStamp |
| 57 | c.frameStamp = currStamp |
| 58 | |
| 59 | c.elapsStamp += c.deltaStamp |
| 60 | if secondsInNano <= c.elapsStamp { |
| 61 | c.elapsStamp %= secondsInNano |
| 62 | c.perSecond = c.counter |
| 63 | c.counter = 0 |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // Delta is the amount of seconds between the last tick and the one before that |
| 68 | func (c *Clock) Delta() float32 { |