* update * @ignore
(time: number)
| 229 | * @ignore |
| 230 | */ |
| 231 | update(time: number) { |
| 232 | this.last = this.now; |
| 233 | this.now = time; |
| 234 | this.delta = this.now - this.last; |
| 235 | |
| 236 | // fix for negative timestamp returned by wechat or chrome on startup |
| 237 | if (this.delta < 0) { |
| 238 | this.delta = 0; |
| 239 | } |
| 240 | |
| 241 | // get the game tick |
| 242 | this.tick = |
| 243 | this.delta > this.minstep && this.interpolation |
| 244 | ? this.delta / this.step |
| 245 | : 1; |
| 246 | |
| 247 | // update the running FPS estimate (averaged over the last 10 frames) |
| 248 | this.framecount++; |
| 249 | this.framedelta += this.delta; |
| 250 | if (this.framecount % 10 === 0) { |
| 251 | this.fps = clamp( |
| 252 | Math.round((1000 * this.framecount) / this.framedelta), |
| 253 | 0, |
| 254 | this.maxfps, |
| 255 | ); |
| 256 | this.framedelta = 0; |
| 257 | this.framecount = 0; |
| 258 | } |
| 259 | |
| 260 | this.updateTimers(); |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * clear Timers |
no test coverage detected