clean old draw code

This commit is contained in:
Alexander Popov 2023-04-23 18:55:22 +03:00
parent 4ad80bcc7d
commit e652dfba1f
Signed by: iiiypuk
GPG Key ID: E47FE0AB36CD5ED6

View File

@ -14,80 +14,21 @@ export class Scene {
} }
run() { run() {
this.#update();
this.#draw();
}
#update() {
// read layers & draw items
this.#layers.forEach((layer) => { this.#layers.forEach((layer) => {
layer.objects().forEach((item) => { layer.objects().forEach((item) => {
if (typeof item.ticker == 'function') { if (typeof item.ticker == 'function') {
item.ticker(); item.ticker();
} }
});
});
}
#draw() {
// read layers & draw items
this.#layers.forEach((layer) => {
layer.objects().forEach((item) => {
if (typeof item.draw == 'function') { if (typeof item.draw == 'function') {
item.draw(this.#context, true); item.draw(this.#context, true);
} else { } else {
console.log(`⛔ Error display '${item.constructor.name}' object.`); console.log(`⛔ Error display '${item.constructor.name}' object.`);
} }
// switch (item.constructor.name) {
// case 'Rect':
// this.#drawRect(item.x, item.y, item.width, item.height, item.fillColor);
// break;
// case 'StrokeRect':
// this.#drawStrokeRect(
// item.x,
// item.y,
// item.width,
// item.height,
// item.fillColor,
// item.strokeColor,
// item.strokeWidth
// );
// break;
// case 'Sprite':
// this.#drawSprite(item);
// break;
// default:
// console.log(`⛔ Error display '${item.constructor.name}' object.`);
// }
}); });
}); });
} }
// #drawRect(x, y, w, h, fillColor) {
// this.#context.fillStyle = fillColor;
// this.#context.fillRect(x, y, w, h);
// }
// #drawStrokeRect(x, y, w, h, fillColor, strokeColor, strokeWidth) {
// this.#drawRect(x, y, w, h, fillColor);
// this.#context.lineWidth = strokeWidth;
// this.#context.strokeStyle = strokeColor;
// this.#context.strokeRect(x, y, w, h);
// }
// #drawSprite(image) {
// if (image.loaded != true) {
// return -1;
// }
// this.#context.drawImage(image.image(), image.x, image.y);
// }
addLayer(layer) { addLayer(layer) {
this.#layers.push(layer); this.#layers.push(layer);
} }