1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-04 22:04:29 +00:00

Merge pull request #500 from FunkinCrew/bugfix/weekend-1-can-death-freeze

Preload Pico explosion death so the game doesn't stutter when you die to the can
This commit is contained in:
Cameron Taylor 2024-04-23 04:24:53 -04:00 committed by GitHub
commit 4fada0fd4e
8 changed files with 120 additions and 40 deletions

5
.gitignore vendored
View file

@ -8,3 +8,8 @@ RECOVER_*.fla
shitAudio/ shitAudio/
.build_time .build_time
.swp .swp
# Exclude JS stuff
node_modules/
package.json
package-lock.json

2
assets

@ -1 +1 @@
Subproject commit 9676d494146008bb99cd718fadffa3610a659ad4 Subproject commit 3f3977d7bf82856106e9c74fa11433c67b160323

View file

@ -39,27 +39,39 @@ class Conductor
static var _instance:Null<Conductor> = null; static var _instance:Null<Conductor> = null;
static function get_instance():Conductor
{
if (_instance == null) _instance = new Conductor();
return _instance;
}
/** /**
* Signal fired when the current Conductor instance advances to a new measure. * Signal fired when the current static Conductor instance advances to a new measure.
*/ */
public static var measureHit(default, null):FlxSignal = new FlxSignal(); public static var measureHit(default, null):FlxSignal = new FlxSignal();
/**
* Signal fired when THIS Conductor instance advances to a new measure.
* TODO: This naming sucks but we can't make a static and instance field with the same name!
*/
public var onMeasureHit(default, null):FlxSignal = new FlxSignal();
/** /**
* Signal fired when the current Conductor instance advances to a new beat. * Signal fired when the current Conductor instance advances to a new beat.
*/ */
public static var beatHit(default, null):FlxSignal = new FlxSignal(); public static var beatHit(default, null):FlxSignal = new FlxSignal();
/**
* Signal fired when THIS Conductor instance advances to a new beat.
* TODO: This naming sucks but we can't make a static and instance field with the same name!
*/
public var onBeatHit(default, null):FlxSignal = new FlxSignal();
/** /**
* Signal fired when the current Conductor instance advances to a new step. * Signal fired when the current Conductor instance advances to a new step.
*/ */
public static var stepHit(default, null):FlxSignal = new FlxSignal(); public static var stepHit(default, null):FlxSignal = new FlxSignal();
/**
* Signal fired when THIS Conductor instance advances to a new step.
* TODO: This naming sucks but we can't make a static and instance field with the same name!
*/
public var onStepHit(default, null):FlxSignal = new FlxSignal();
/** /**
* The list of time changes in the song. * The list of time changes in the song.
* There should be at least one time change (at the beginning of the song) to define the BPM. * There should be at least one time change (at the beginning of the song) to define the BPM.
@ -247,6 +259,69 @@ class Conductor
return Std.int(timeSignatureNumerator / timeSignatureDenominator * Constants.STEPS_PER_BEAT * Constants.STEPS_PER_BEAT); return Std.int(timeSignatureNumerator / timeSignatureDenominator * Constants.STEPS_PER_BEAT * Constants.STEPS_PER_BEAT);
} }
/**
* Reset the Conductor, replacing the current instance with a fresh one.
*/
public static function reset():Void
{
set_instance(new Conductor());
}
static function dispatchMeasureHit():Void
{
Conductor.measureHit.dispatch();
}
static function dispatchBeatHit():Void
{
Conductor.beatHit.dispatch();
}
static function dispatchStepHit():Void
{
Conductor.stepHit.dispatch();
}
static function setupSingleton(input:Conductor):Void
{
input.onMeasureHit.add(dispatchMeasureHit);
input.onBeatHit.add(dispatchBeatHit);
input.onStepHit.add(dispatchStepHit);
}
static function clearSingleton(input:Conductor):Void
{
input.onMeasureHit.remove(dispatchMeasureHit);
input.onBeatHit.remove(dispatchBeatHit);
input.onStepHit.remove(dispatchStepHit);
}
static function get_instance():Conductor
{
if (Conductor._instance == null) set_instance(new Conductor());
if (Conductor._instance == null) throw "Could not initialize singleton Conductor!";
return Conductor._instance;
}
static function set_instance(instance:Conductor):Conductor
{
// Use _instance in here to avoid recursion
if (Conductor._instance != null) clearSingleton(Conductor._instance);
Conductor._instance = instance;
if (Conductor._instance != null) setupSingleton(Conductor._instance);
return Conductor._instance;
}
/**
* The constructor.
*/
public function new() {} public function new() {}
/** /**
@ -257,6 +332,7 @@ class Conductor
* *
* WARNING: Avoid this for things like setting the BPM of the title screen music, * WARNING: Avoid this for things like setting the BPM of the title screen music,
* you should have a metadata file for it instead. * you should have a metadata file for it instead.
* We should probably deprecate this in the future.
*/ */
public function forceBPM(?bpm:Float):Void public function forceBPM(?bpm:Float):Void
{ {
@ -277,7 +353,7 @@ class Conductor
* BPM, current step, etc. will be re-calculated based on the song position. * BPM, current step, etc. will be re-calculated based on the song position.
* *
* @param songPosition The current position in the song in milliseconds. * @param songPosition The current position in the song in milliseconds.
* Leave blank to use the FlxG.sound.music position. * Leave blank to use the `FlxG.sound.music` position.
*/ */
public function update(?songPos:Float):Void public function update(?songPos:Float):Void
{ {
@ -330,24 +406,20 @@ class Conductor
this.currentMeasure = Math.floor(currentMeasureTime); this.currentMeasure = Math.floor(currentMeasureTime);
} }
// Only fire the signal if we are THE Conductor. // FlxSignals are really cool.
if (this == Conductor.instance) if (currentStep != oldStep)
{ {
// FlxSignals are really cool. this.onStepHit.dispatch();
if (currentStep != oldStep) }
{
Conductor.stepHit.dispatch();
}
if (currentBeat != oldBeat) if (currentBeat != oldBeat)
{ {
Conductor.beatHit.dispatch(); this.onBeatHit.dispatch();
} }
if (currentMeasure != oldMeasure) if (currentMeasure != oldMeasure)
{ {
Conductor.measureHit.dispatch(); this.onMeasureHit.dispatch();
}
} }
} }
@ -517,20 +589,14 @@ class Conductor
/** /**
* Add variables of the current Conductor instance to the Flixel debugger. * Add variables of the current Conductor instance to the Flixel debugger.
*/ */
public static function watchQuick():Void public static function watchQuick(?target:Conductor):Void
{ {
FlxG.watch.addQuick('songPosition', Conductor.instance.songPosition); if (target == null) target = Conductor.instance;
FlxG.watch.addQuick('bpm', Conductor.instance.bpm);
FlxG.watch.addQuick('currentMeasureTime', Conductor.instance.currentMeasureTime);
FlxG.watch.addQuick('currentBeatTime', Conductor.instance.currentBeatTime);
FlxG.watch.addQuick('currentStepTime', Conductor.instance.currentStepTime);
}
/** FlxG.watch.addQuick('songPosition', target.songPosition);
* Reset the Conductor, replacing the current instance with a fresh one. FlxG.watch.addQuick('bpm', target.bpm);
*/ FlxG.watch.addQuick('currentMeasureTime', target.currentMeasureTime);
public static function reset():Void FlxG.watch.addQuick('currentBeatTime', target.currentBeatTime);
{ FlxG.watch.addQuick('currentStepTime', target.currentStepTime);
_instance = new Conductor();
} }
} }

View file

@ -37,6 +37,11 @@ class FlxAtlasSprite extends FlxAnimate
{ {
if (settings == null) settings = SETTINGS; if (settings == null) settings = SETTINGS;
if (path == null)
{
throw 'Null path specified for FlxAtlasSprite!';
}
super(x, y, path, settings); super(x, y, path, settings);
if (this.anim.curInstance == null) if (this.anim.curInstance == null)

View file

@ -813,6 +813,7 @@ class PlayState extends MusicBeatSubState
super.update(elapsed); super.update(elapsed);
var list = FlxG.sound.list;
updateHealthBar(); updateHealthBar();
updateScoreText(); updateScoreText();
@ -969,7 +970,7 @@ class PlayState extends MusicBeatSubState
if (health < Constants.HEALTH_MIN) health = Constants.HEALTH_MIN; if (health < Constants.HEALTH_MIN) health = Constants.HEALTH_MIN;
// Apply camera zoom + multipliers. // Apply camera zoom + multipliers.
if (subState == null && cameraZoomRate > 0.0 && !isInCutscene) if (subState == null && cameraZoomRate > 0.0) // && !isInCutscene)
{ {
cameraBopMultiplier = FlxMath.lerp(1.0, cameraBopMultiplier, 0.95); // Lerp bop multiplier back to 1.0x cameraBopMultiplier = FlxMath.lerp(1.0, cameraBopMultiplier, 0.95); // Lerp bop multiplier back to 1.0x
var zoomPlusBop = currentCameraZoom * cameraBopMultiplier; // Apply camera bop multiplier. var zoomPlusBop = currentCameraZoom * cameraBopMultiplier; // Apply camera bop multiplier.
@ -1869,6 +1870,8 @@ class PlayState extends MusicBeatSubState
isInCutscene = false; isInCutscene = false;
camCutscene.visible = false; camCutscene.visible = false;
// TODO: Maybe tween in the camera after any cutscenes.
camHUD.visible = true; camHUD.visible = true;
} }

View file

@ -127,7 +127,7 @@ class FocusCameraSongEvent extends SongEvent
switch (ease) switch (ease)
{ {
case 'CLASSIC': // Old-school. No ease. Just set follow point. case 'CLASSIC': // Old-school. No ease. Just set follow point.
PlayState.instance.cancelCameraFollowTween(); PlayState.instance.resetCamera();
PlayState.instance.cameraFollowPoint.setPosition(targetX, targetY); PlayState.instance.cameraFollowPoint.setPosition(targetX, targetY);
case 'INSTANT': // Instant ease. Duration is automatically 0. case 'INSTANT': // Instant ease. Duration is automatically 0.
PlayState.instance.tweenCameraToPosition(targetX, targetY, 0); PlayState.instance.tweenCameraToPosition(targetX, targetY, 0);

View file

@ -332,6 +332,7 @@ class LoadingState extends MusicBeatSubState
// Since FlxGraphic tells OpenFL to not cache it, we have to do it manually. // Since FlxGraphic tells OpenFL to not cache it, we have to do it manually.
if (path.endsWith('spritemap1.png')) if (path.endsWith('spritemap1.png'))
{ {
trace('Preloading FlxAnimate asset: ${path}');
openfl.Assets.getBitmapData(path, true); openfl.Assets.getBitmapData(path, true);
} }
} }

View file

@ -218,7 +218,7 @@ class Constants
public static final DEFAULT_VARIATION:String = 'default'; public static final DEFAULT_VARIATION:String = 'default';
/** /**
* Standard variations used by the game. * Standardized variations for charts
*/ */
public static final DEFAULT_VARIATION_LIST:Array<String> = ['default', 'erect', 'pico']; public static final DEFAULT_VARIATION_LIST:Array<String> = ['default', 'erect', 'pico'];