MCPcopy Create free account
hub / github.com/melonjs/melonJS / update

Method update

packages/melonjs/src/system/timer.ts:231–261  ·  view source on GitHub ↗

* update * @ignore

(time: number)

Source from the content-addressed store, hash-verified

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

Callers 1

constructorMethod · 0.95

Calls 2

updateTimersMethod · 0.95
clampFunction · 0.90

Tested by

no test coverage detected