Compare commits
3 Commits
f3b63e0311
...
1a3ce1fe97
Author | SHA1 | Date |
---|---|---|
Alexander Popov | 1a3ce1fe97 | |
Alexander Popov | bdec83fd32 | |
Alexander Popov | cc8a51749a |
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.prevTime = 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);
|
||||
|
|
|
@ -65,6 +65,7 @@ export class Sprite {
|
|||
this.angle = 0;
|
||||
this.src = src;
|
||||
this.srcOld = this.src;
|
||||
this.ticker = null;
|
||||
|
||||
this.loaded = false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue