В настоящее время я получаю эту ошибку: < /p>
Код: Выделить всё
Uncaught (in promise) ReferenceError: poopengine is not defined
http://127.0.0.1:5500/poopengine.mjs line 408 > eval:1
attributeChangedCallback http://127.0.0.1:5500/poopengine.mjs:408
promise callback*attributeChangedCallback/< http://127.0.0.1:5500/poopengine.mjs:403
promise callback*attributeChangedCallback http://127.0.0.1:5500/poopengine.mjs:403
http://127.0.0.1:5500/poopengine.mjs:413
index.html
Код: Выделить всё
Document
body {
padding: 0;
margin: 0;
overflow: hidden;
}
Код: Выделить всё
const originalStart = poopengine.start;
poopengine.start = function () {
originalStart.apply(this);
const box = poopengine.object({
width: 50,
height: 50,
x: 0,
y: 0,
colour: 'blue'
});
}
const originalUpdate = poopengine.update;
poopengine.update = function () {
originalUpdate.apply(this);
// Code goes here:
}
poopengine.resize = function () {
// Code goes here:
}
poopengine.start();
< /code>
poopengine.mjs
class poopengine_class {
constructor(canvas) {
this.canvas = canvas;
this.display = { width: 300, height: 200 };
this.context = null;
this.objects = [];
this.input = new class input {
constructor() {
this.keydown = null;
this.keypressed = null;
this.keyup = null;
this.click = null;
this.mousedown = null;
this.mouseup = null;
this.mouse_pos = { x: null, y: null };
this.hovering = function (object) {
if (this.mouse_pos.x != null) {
const index = poopengine.objects.indexOf(object);
const array = poopengine.objects.slice(index + 1);
for (let i = 0; i < array.length; i++) {
if (
this.mouse_pos.x >= array[i].x &&
this.mouse_pos.x = array[i].y &&
this.mouse_pos.y = object.x &&
this.mouse_pos.x = object.y &&
this.mouse_pos.y {
this.resize();
};
// Mouse input
window.addEventListener("mousedown", () => {
this.input.mousedown = true;
});
window.addEventListener("click", () => {
if (this.input.click == null) {
this.input.click = true;
setTimeout(() => {
this.input.click = null;
}, 10);
}
});
window.addEventListener("mouseup", () => {
this.input.mouseup = true;
this.input.mousedown = null;
setTimeout(() => {
this.input.mouseup = null;
}, 10);
});
window.addEventListener("mousemove", (event) => {
this.input.mouse_pos = { x: event.clientX, y: event.clientY };
});
// Input
window.addEventListener("keydown", (event) => {
this.input.keydown = event.key;
});
window.addEventListener("keypress", (event) => {
if (this.input.keypressed == null) {
this.input.keypressed = event.key;
setTimeout(() => {
this.input.keypressed = null;
}, 10);
}
});
window.addEventListener("keyup", (event) => {
this.input.keyup = event.key;
this.input.keydown = null;
setTimeout(() => {
this.input.keyup = null;
}, 10);
});
window.requestAnimationFrame(() => this.update());
};
this.update = function () {
this.context.reset()
window.requestAnimationFrame(() => this.update());
this.context.clearRect(0, 0, this.display.width, this.display.height);
// Fps and delta calculation
const now = performance.now();
if (this.times.length > 0) {
this.deltaTime = now - this.times[this.times.length - 1];
}
while (this.times.length > 0 && this.times[0] {
val += increase;
if (val >= until && isBigger) {
if (finish != undefined) {
finsish()
}
clearInterval(inter);
val = until;
} else if (val res.text().then(scr => {
const shadowRoot = this.attachShadow({ mode: 'open' });
const canvas = document.createElement('canvas');
shadowRoot.append(canvas);
const localPoopengine = new poopengine_class(canvas);
eval(scr);
}));
}
}
customElements.define("poopengine-window", poopengine_component);
Подробнее здесь: https://stackoverflow.com/questions/793 ... y-variable
Мобильная версия