song reset redo to make shit reload faster

This commit is contained in:
Cameron Taylor 2021-09-24 11:51:15 -04:00
parent 707c7b6f0a
commit c5bca599ad
4 changed files with 58 additions and 25 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 3 AWESOME PICO VS. DARNELL SONGS!! - 3 AWESOME PICO VS. DARNELL SONGS!!
- Character offset editor / spritesheet viewer - Character offset editor / spritesheet viewer
## Changed ## Changed
- Resetting from game over and "restart song" should be faster
- Health gain is different depending on how accurate you hit notes! - Health gain is different depending on how accurate you hit notes!
- slight less health gained on sustain notes - slight less health gained on sustain notes
- The wave-y effect on Thorns for the school is now a shader, instead of a pre-baked animation! - The wave-y effect on Thorns for the school is now a shader, instead of a pre-baked animation!

View File

@ -3,6 +3,7 @@ package;
import flixel.FlxObject; import flixel.FlxObject;
import flixel.FlxSubState; import flixel.FlxSubState;
import flixel.math.FlxPoint; import flixel.math.FlxPoint;
import flixel.system.FlxSound;
import flixel.util.FlxColor; import flixel.util.FlxColor;
import flixel.util.FlxTimer; import flixel.util.FlxTimer;
import haxe.display.Display.Package; import haxe.display.Display.Package;
@ -16,8 +17,13 @@ class GameOverSubstate extends MusicBeatSubstate
var stageSuffix:String = ""; var stageSuffix:String = "";
var randomGameover:Int = 1; var randomGameover:Int = 1;
var gameOverMusic:FlxSound;
public function new(x:Float, y:Float) public function new(x:Float, y:Float)
{ {
gameOverMusic = new FlxSound();
FlxG.sound.list.add(gameOverMusic);
var daStage = PlayState.curStage; var daStage = PlayState.curStage;
var daBf:String = ''; var daBf:String = '';
switch (daStage) switch (daStage)
@ -48,7 +54,7 @@ class GameOverSubstate extends MusicBeatSubstate
add(camFollow); add(camFollow);
FlxG.sound.play(Paths.sound('fnf_loss_sfx' + stageSuffix)); FlxG.sound.play(Paths.sound('fnf_loss_sfx' + stageSuffix));
Conductor.changeBPM(100); // Conductor.changeBPM(100);
switch (PlayState.SONG.player1) switch (PlayState.SONG.player1)
{ {
@ -58,6 +64,8 @@ class GameOverSubstate extends MusicBeatSubstate
// FlxG.camera.followLerp = 1; // FlxG.camera.followLerp = 1;
// FlxG.camera.focusOn(FlxPoint.get(FlxG.width / 2, FlxG.height / 2)); // FlxG.camera.focusOn(FlxPoint.get(FlxG.width / 2, FlxG.height / 2));
// commented out for now
FlxG.camera.scroll.set(); FlxG.camera.scroll.set();
FlxG.camera.target = null; FlxG.camera.target = null;
@ -99,7 +107,8 @@ class GameOverSubstate extends MusicBeatSubstate
{ {
PlayState.deathCounter = 0; PlayState.deathCounter = 0;
PlayState.seenCutscene = false; PlayState.seenCutscene = false;
FlxG.sound.music.stop(); // FlxG.sound.music.stop();
gameOverMusic.stop();
if (PlayState.isStoryMode) if (PlayState.isStoryMode)
FlxG.switchState(new StoryMenuState()); FlxG.switchState(new StoryMenuState());
@ -125,7 +134,10 @@ class GameOverSubstate extends MusicBeatSubstate
FlxG.sound.play(Paths.sound('jeffGameover/jeffGameover-' + randomGameover), 1, false, null, true, function() FlxG.sound.play(Paths.sound('jeffGameover/jeffGameover-' + randomGameover), 1, false, null, true, function()
{ {
if (!isEnding) if (!isEnding)
FlxG.sound.music.fadeIn(4, 0.2, 1); {
gameOverMusic.fadeIn(4, 0.2, 1);
}
// FlxG.sound.music.fadeIn(4, 0.2, 1);
}); });
} }
default: default:
@ -136,23 +148,21 @@ class GameOverSubstate extends MusicBeatSubstate
} }
} }
if (FlxG.sound.music.playing) if (gameOverMusic.playing)
{ {
Conductor.songPosition = FlxG.sound.music.time; Conductor.songPosition = gameOverMusic.time;
} }
} }
private function coolStartDeath(?vol:Float = 1):Void private function coolStartDeath(?vol:Float = 1):Void
{ {
if (!isEnding) if (!isEnding)
FlxG.sound.playMusic(Paths.music('gameOver' + stageSuffix), vol); {
} gameOverMusic.loadEmbedded(Paths.music('gameOver' + stageSuffix));
gameOverMusic.volume = vol;
override function beatHit() gameOverMusic.play();
{ }
super.beatHit(); // FlxG.sound.playMusic();
FlxG.log.add('beat');
} }
var isEnding:Bool = false; var isEnding:Bool = false;
@ -163,14 +173,17 @@ class GameOverSubstate extends MusicBeatSubstate
{ {
isEnding = true; isEnding = true;
bf.playAnim('deathConfirm', true); bf.playAnim('deathConfirm', true);
FlxG.sound.music.stop(); gameOverMusic.stop();
// FlxG.sound.music.stop();
FlxG.sound.play(Paths.music('gameOverEnd' + stageSuffix)); FlxG.sound.play(Paths.music('gameOverEnd' + stageSuffix));
new FlxTimer().start(0.7, function(tmr:FlxTimer) new FlxTimer().start(0.7, function(tmr:FlxTimer)
{ {
FlxG.camera.fade(FlxColor.BLACK, 2, false, function() FlxG.camera.fade(FlxColor.BLACK, 2, false, function()
{ {
// close(); FlxG.camera.fade(FlxColor.BLACK, 1, true, null, true);
LoadingState.loadAndSwitchState(new PlayState()); PlayState.needsReset = true;
close();
// LoadingState.loadAndSwitchState(new PlayState());
}); });
}); });
} }

View File

@ -174,7 +174,10 @@ class PauseSubState extends MusicBeatSubstate
menuItems = pauseOG; menuItems = pauseOG;
regenMenu(); regenMenu();
case "Restart Song": case "Restart Song":
FlxG.resetState(); PlayState.needsReset = true;
close();
// FlxG.resetState();
case "Exit to menu": case "Exit to menu":
PlayState.seenCutscene = false; PlayState.seenCutscene = false;
PlayState.deathCounter = 0; PlayState.deathCounter = 0;

View File

@ -46,6 +46,7 @@ class PlayState extends MusicBeatState
public static var storyDifficulty:Int = 1; public static var storyDifficulty:Int = 1;
public static var deathCounter:Int = 0; public static var deathCounter:Int = 0;
public static var practiceMode:Bool = false; public static var practiceMode:Bool = false;
public static var needsReset:Bool = false;
var halloweenLevel:Bool = false; var halloweenLevel:Bool = false;
@ -708,10 +709,7 @@ class PlayState extends MusicBeatState
add(camFollow); add(camFollow);
FlxG.camera.follow(camFollow, LOCKON, 0.04); resetCamFollow();
// FlxG.camera.setScrollBounds(0, FlxG.width, 0, FlxG.height);
FlxG.camera.zoom = defaultCamZoom;
FlxG.camera.focusOn(camFollow.getPosition());
FlxG.worldBounds.set(0, 0, FlxG.width, FlxG.height); FlxG.worldBounds.set(0, 0, FlxG.width, FlxG.height);
@ -1831,11 +1829,19 @@ class PlayState extends MusicBeatState
#else #else
if (FlxG.keys.justPressed.H) if (FlxG.keys.justPressed.H)
camHUD.visible = !camHUD.visible; camHUD.visible = !camHUD.visible;
if (FlxG.keys.justPressed.K) if (needsReset)
{ {
resetCamFollow();
paused = false;
persistentUpdate = true;
persistentDraw = true;
startingSong = true; startingSong = true;
FlxG.sound.music.pause(); FlxG.sound.music.pause();
vocals.pause();
FlxG.sound.music.time = 0; FlxG.sound.music.time = 0;
regenNoteData(); regenNoteData();
health = 1; health = 1;
@ -1846,6 +1852,8 @@ class PlayState extends MusicBeatState
restartCountdownTimer(); restartCountdownTimer();
needsReset = false;
// FlxScreenGrab.grab(null, true, true); // FlxScreenGrab.grab(null, true, true);
/* /*
@ -1978,7 +1986,7 @@ class PlayState extends MusicBeatState
var iconOffset:Int = 26; var iconOffset:Int = 26;
iconP1.x = healthBar.x + (healthBar.width * (FlxMath.remapToRange(healthBar.value, 0, 2, 100, 0) * 0.01) - iconOffset); iconP1.x = healthBar.x + (healthBar.width * (FlxMath.remapToRange(healthBar.value, 0, 2, 100, 0) * 0.01) - iconOffset);
iconP2.x = healthBar.x + (healthBar.width * (FlxMath.remapToRange(healthBar.percent, 0, 2, 100, 0) * 0.01)) - (iconP2.width - iconOffset); iconP2.x = healthBar.x + (healthBar.width * (FlxMath.remapToRange(healthBar.value, 0, 2, 100, 0) * 0.01)) - (iconP2.width - iconOffset);
if (health > 2) if (health > 2)
health = 2; health = 2;
@ -2063,8 +2071,8 @@ class PlayState extends MusicBeatState
persistentDraw = false; persistentDraw = false;
paused = true; paused = true;
vocals.stop(); vocals.pause();
FlxG.sound.music.stop(); FlxG.sound.music.pause();
// unloadAssets(); // unloadAssets();
@ -2903,6 +2911,14 @@ class PlayState extends MusicBeatState
} }
} }
function resetCamFollow():Void
{
FlxG.camera.follow(camFollow, LOCKON, 0.04);
// FlxG.camera.setScrollBounds(0, FlxG.width, 0, FlxG.height);
FlxG.camera.zoom = defaultCamZoom;
FlxG.camera.focusOn(camFollow.getPosition());
}
var fastCarCanDrive:Bool = true; var fastCarCanDrive:Bool = true;
function resetFastCar():Void function resetFastCar():Void