Skip to content

Commit

Permalink
Fix objects refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
solstice23 committed May 13, 2024
1 parent 1e745f6 commit 08baf1b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/modules/Main/Playfield/ObjectsCanvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class PixiManager {
this.height = this?.app?.canvas?.offsetHeight ?? this.parent.offsetHeight;
this.applyToAllFruits(fruit => fruit.updatePosition());
this.applyToAllFruits(fruit => fruit.updateSize());
this.render(true);
});
canvasResizeObserver.observe(this.app.canvas);

Expand Down Expand Up @@ -178,8 +179,8 @@ class PixiManager {
}
setObjects(objects) {
this.objects = objects;
//if (this.rendering) this.initFruits();
this.applyToAllFruits(fruit => fruit.updateVisualStyle());
if (this.rendering) this.initFruits();
//this.applyToAllFruits(fruit => fruit.updateVisualStyle());
}
setRendering(rendering) {
this.rendering = rendering;
Expand All @@ -194,6 +195,7 @@ class PixiManager {
const fruit = new Fruit(this, obj);
this.fruits.push(fruit);
}
this.render(true);
}

applyToAllFruits(func) {
Expand All @@ -202,14 +204,14 @@ class PixiManager {
}
}

render() {
render(force = false) {
if (!this.fruits.length) this.initFruits();

const currentTime = this.getTime();
if (currentTime == this.lastTime) { this.lastTime = currentTime; return; }
if (currentTime == this.lastTime && !force) { this.lastTime = currentTime; return; }
const preempt = this.getPreempt();
const startTime = currentTime - 200, endTime = currentTime + preempt + 200;
if (Math.abs(currentTime - this.lastTime) > 20000) {
if (Math.abs(currentTime - this.lastTime) > 20000 || force) {
//console.log("Jumped");
this.L = binarySearch(this.objects, startTime);
for (this.R = this.L; this.R < this.objects.length && this.objects[this.R].time <= endTime; this.R++) {
Expand Down

0 comments on commit 08baf1b

Please sign in to comment.