fix rewind particles

This commit is contained in:
RandomityGuy 2023-05-06 23:32:50 +05:30
parent 7818fb8bb5
commit 533037f95b
3 changed files with 14 additions and 4 deletions

View file

@ -931,6 +931,8 @@ class MarbleWorld extends Scheduler {
}
}
var realDt = dt;
if (Key.isDown(Key.R)) {
this.rewinding = true;
} else {
@ -965,7 +967,10 @@ class MarbleWorld extends Scheduler {
ProfilerUI.measure("updateInstances");
this.instanceManager.update(dt);
ProfilerUI.measure("updateParticles");
this.particleManager.update(1000 * timeState.timeSinceLoad, dt);
if (this.rewinding) {
this.particleManager.update(1000 * timeState.timeSinceLoad, -realDt);
} else
this.particleManager.update(1000 * timeState.timeSinceLoad, dt);
ProfilerUI.measure("updatePlayGui");
this.playGui.update(timeState);
ProfilerUI.measure("updateAudio");

View file

@ -75,13 +75,13 @@ class Particle {
var elapsed = time - this.spawnTime;
var completion = Util.clamp(elapsed / this.lifeTime, 0, 1);
if (currentAge > this.lifeTime) // Again, rewind needs this
if (currentAge > this.lifeTime || currentAge < 0) // Again, rewind needs this
{
this.manager.removeParticle(this.data, this);
return;
}
if (completion == 1) {
if (completion == 1 || completion < 0) {
// The particle can die
this.manager.removeParticle(this.data, this);
return;

View file

@ -50,6 +50,7 @@ typedef ControlsSettings = {
var alwaysFreeLook:Bool;
var cameraSensitivity:Float;
var invertYAxis:Bool;
var rewind:Int;
}
typedef TouchSettings = {
@ -108,7 +109,8 @@ class Settings {
freelook: Key.MOUSE_RIGHT,
alwaysFreeLook: true,
cameraSensitivity: 0.6,
invertYAxis: false
invertYAxis: false,
rewind: Key.R,
};
public static var touchSettings:TouchSettings = {
@ -254,6 +256,9 @@ class Settings {
if (json.gamepad != null) {
gamepadSettings = json.gamepad;
}
if (controlsSettings.rewind == null) {
controlsSettings.rewind = Key.R;
}
progression = json.progression;
highscoreName = json.highscoreName;
} else {