fix rewind particles

This commit is contained in:
RandomityGuy 2023-05-06 23:32:50 +05:30
parent e6b5dbbb25
commit 35d215412f
3 changed files with 14 additions and 4 deletions

View file

@ -1005,6 +1005,8 @@ class MarbleWorld extends Scheduler {
}
}
var realDt = dt;
if (Key.isDown(Key.R)) {
this.rewinding = true;
} else {
@ -1085,7 +1087,10 @@ class MarbleWorld extends Scheduler {
ProfilerUI.measure("updateInstances");
this.instanceManager.render();
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

@ -76,13 +76,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

@ -62,6 +62,7 @@ typedef ControlsSettings = {
var invertYAxis:Bool;
var respawn:Int;
var blast:Int;
var rewind:Int;
}
typedef TouchSettings = {
@ -143,7 +144,8 @@ class Settings {
cameraSensitivity: 0.6,
invertYAxis: false,
respawn: Key.BACKSPACE,
blast: Key.E
blast: Key.E,
rewind: Key.R,
};
public static var touchSettings:TouchSettings = {
@ -396,6 +398,9 @@ class Settings {
if (controlsSettings.blast == null) {
controlsSettings.blast = Key.E;
}
if (controlsSettings.rewind == null) {
controlsSettings.rewind = Key.R;
}
#end
highscoreName = json.highscoreName;
} else {