feat(#8): improve debug
This commit is contained in:
parent
4e2905cf96
commit
731a32303a
8 changed files with 84 additions and 88 deletions
21
modules/game-objects/fps-counter.js
Normal file
21
modules/game-objects/fps-counter.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { GameObject } from "./game-object.js";
|
||||
|
||||
export class FpsCounter extends GameObject {
|
||||
constructor({ debug = false }) {
|
||||
super({ debug });
|
||||
this.fps = 0;
|
||||
}
|
||||
|
||||
update(delta) {
|
||||
this.fps = Math.floor(1 / delta);
|
||||
}
|
||||
|
||||
render(ctx) {
|
||||
if (!this.debug) {
|
||||
return;
|
||||
}
|
||||
ctx.fillStyle = "Red";
|
||||
ctx.font = "normal 12pt Arial";
|
||||
ctx.fillText(this.fps + " fps", 5, 15);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue