Compare commits
No commits in common. "87bc10094ec3db1c80a10d538240c887f1302599" and "1e50ed7a48a7145ce7c1f3a8a93ad97c393fcc75" have entirely different histories.
87bc10094e
...
1e50ed7a48
@ -1,10 +1,8 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
|
||||||
"version": "beeeeeeta",
|
"version": "beeeeeeta",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup --config rollup.config.js",
|
"build": "rm -rf ./dist/ && rollup src/js/main.js --file dist/engine-$(npm pkg get version | tr -d '\"').js --format es",
|
||||||
"watch": "ROLLUP_WATCH=true rollup --config rollup.config.js --watch",
|
|
||||||
"prettier-check": "prettier --check .",
|
"prettier-check": "prettier --check .",
|
||||||
"prettier-write": "prettier --write .",
|
"prettier-write": "prettier --write .",
|
||||||
"editorconfig-check": "ec -exclude 'node_modules' .",
|
"editorconfig-check": "ec -exclude 'node_modules' .",
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
import pkg from './package.json' assert { type: 'json' };
|
|
||||||
|
|
||||||
export default {
|
|
||||||
input: 'src/main.js',
|
|
||||||
output: {
|
|
||||||
file: `dist/engine-${pkg.version}.js`,
|
|
||||||
format: 'es',
|
|
||||||
},
|
|
||||||
};
|
|
@ -1,7 +1,7 @@
|
|||||||
import { Settings } from './settings.js';
|
import { Settings } from './settings.js';
|
||||||
import { Pointer } from './pointer.js';
|
import { Pointer } from './pointer.js';
|
||||||
import { Scene, SceneLayer } from './scene.js';
|
import { Scene, SceneLayer } from './scene.js';
|
||||||
import { Rect, StrokeRect, Sprite, TiledSprite, Empty } from './objects.js';
|
import { Rect, StrokeRect, Sprite, TiledSprite } from './objects.js';
|
||||||
|
|
||||||
export class App {
|
export class App {
|
||||||
#version;
|
#version;
|
||||||
@ -73,4 +73,4 @@ export class App {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Scene, SceneLayer, Empty, Rect, StrokeRect, Sprite, TiledSprite };
|
export { Scene, SceneLayer, Rect, StrokeRect, Sprite, TiledSprite };
|
@ -8,12 +8,6 @@ class Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Empty {
|
|
||||||
constructor() {
|
|
||||||
this.ticker = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Rect extends Object {
|
export class Rect extends Object {
|
||||||
constructor(x, y, w, h, fillColor = 'white') {
|
constructor(x, y, w, h, fillColor = 'white') {
|
||||||
super(x, y, w, h);
|
super(x, y, w, h);
|
||||||
@ -63,15 +57,13 @@ export class Sprite {
|
|||||||
this.width = null;
|
this.width = null;
|
||||||
this.height = null;
|
this.height = null;
|
||||||
this.angle = 0;
|
this.angle = 0;
|
||||||
this.src = src;
|
|
||||||
this.srcOld = this.src;
|
|
||||||
|
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
|
|
||||||
this.#image = new Image();
|
this.#image = new Image();
|
||||||
this.#image.onload = this.#onload();
|
this.#image.onload = this.#onload();
|
||||||
|
|
||||||
this.#image.src = this.src;
|
this.#image.src = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
#onload() {
|
#onload() {
|
||||||
@ -90,11 +82,6 @@ export class Sprite {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.srcOld != this.src) {
|
|
||||||
this.srcOld = this.src;
|
|
||||||
this.#image.src = this.src;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.save();
|
context.save();
|
||||||
context.translate(this.x + this.#image.width / 2, this.y + this.#image.height / 2);
|
context.translate(this.x + this.#image.width / 2, this.y + this.#image.height / 2);
|
||||||
context.rotate((this.angle * Math.PI) / 180);
|
context.rotate((this.angle * Math.PI) / 180);
|
||||||
@ -108,14 +95,9 @@ export class Sprite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class TiledSprite extends Sprite {
|
export class TiledSprite extends Sprite {
|
||||||
#image;
|
|
||||||
|
|
||||||
constructor(src = null, x, y, only = null) {
|
constructor(src = null, x, y, only = null) {
|
||||||
super(src, x, y);
|
super(src, x, y);
|
||||||
|
|
||||||
this.src = src;
|
|
||||||
this.srcOld = this.src;
|
|
||||||
|
|
||||||
this.only = only;
|
this.only = only;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,11 +106,6 @@ export class TiledSprite extends Sprite {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.srcOld != this.src) {
|
|
||||||
this.srcOld = this.src;
|
|
||||||
this.#image.src = this.src;
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw single image
|
// draw single image
|
||||||
context.drawImage(this.image(), this.x, this.y);
|
context.drawImage(this.image(), this.x, this.y);
|
||||||
|
|
@ -23,9 +23,7 @@ export class Scene {
|
|||||||
if (typeof item.draw == 'function') {
|
if (typeof item.draw == 'function') {
|
||||||
item.draw(this.#context, layer.options.debug);
|
item.draw(this.#context, layer.options.debug);
|
||||||
} else {
|
} else {
|
||||||
if (item.constructor.name != 'Empty') {
|
console.log(`⛔ Error display '${item.constructor.name}' object.`);
|
||||||
console.log(`⛔ Error display '${item.constructor.name}' object.`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user