ujs/src/js/app.js

28 lines
596 B
JavaScript

import { Scene } from './scene.js';
import { Settings } from './settings.js';
import { Pointer } from './pointer.js';
export class App {
constructor(w, h) {
this.canvas = document.querySelector('canvas');
this.context = this.canvas.getContext('2d');
this.scene = new Scene(this.canvas, this.context, w, h);
this.prevTime = Date.now();
Pointer.init();
this.run();
}
run = () => {
let newTime = Date.now();
Settings.delta = (newTime - this.prevTime) / 1000;
this.prevTime = newTime;
this.scene.run();
requestAnimationFrame(this.run);
};
}