update app class
This commit is contained in:
parent
cc8a51749a
commit
bdec83fd32
23
src/main.js
23
src/main.js
@ -7,8 +7,8 @@ export class App {
|
||||
#version;
|
||||
|
||||
constructor(
|
||||
w,
|
||||
h,
|
||||
width,
|
||||
height,
|
||||
options = {
|
||||
backgroundColor: '#ffcc68',
|
||||
welcome: true,
|
||||
@ -16,12 +16,12 @@ export class App {
|
||||
) {
|
||||
this.#version = 'beeeeeeta';
|
||||
|
||||
// Create CANVAS element
|
||||
this.view = document.createElement('canvas');
|
||||
|
||||
this.canvas = this.view;
|
||||
this.context = this.canvas.getContext('2d');
|
||||
this.options = options;
|
||||
|
||||
this.options = options;
|
||||
// check options || FIXIT:
|
||||
if (typeof this.options.backgroundColor === 'undefined') {
|
||||
this.options.backgroundColor = '#ffcc68';
|
||||
@ -30,8 +30,7 @@ export class App {
|
||||
this.options.welcome = true;
|
||||
}
|
||||
|
||||
this.scene = new Scene(this.canvas, this.context, w, h);
|
||||
Settings.fpsPrevTime = Date.now();
|
||||
this.scene = new Scene(this.canvas, this.context, width, height);
|
||||
|
||||
const logStrings = [
|
||||
'ujs engine',
|
||||
@ -47,7 +46,9 @@ export class App {
|
||||
}
|
||||
|
||||
Pointer.init();
|
||||
Settings.fpsPrevTime = Date.now();
|
||||
|
||||
// Start :)
|
||||
this.run();
|
||||
}
|
||||
|
||||
@ -58,18 +59,14 @@ export class App {
|
||||
Settings.fpsPrevTime = fpsNewTime;
|
||||
Settings.fps = Math.round(1 / Settings.fpsDelta);
|
||||
|
||||
// clear canvas
|
||||
// Clear canvas
|
||||
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
|
||||
// fill canvas
|
||||
// Fill canvas by default background color
|
||||
this.context.fillStyle = this.options.backgroundColor;
|
||||
this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
|
||||
// draw border
|
||||
this.context.strokeStyle = '#101024';
|
||||
this.context.lineWidth = 1;
|
||||
this.context.strokeRect(5, 5, this.canvas.width - 10, this.canvas.height - 10);
|
||||
|
||||
// Draw scene
|
||||
this.scene.run();
|
||||
|
||||
requestAnimationFrame(this.run);
|
||||
|
Loading…
Reference in New Issue
Block a user