Skip to content

Commit

Permalink
aoa4
Browse files Browse the repository at this point in the history
  • Loading branch information
PurSnake committed Jul 24, 2024
1 parent 7b80fb4 commit fdff812
Show file tree
Hide file tree
Showing 16 changed files with 283 additions and 212 deletions.
17 changes: 17 additions & 0 deletions source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ class Preferences



public static var playPressAfterConfirm(get, set):Bool;

static function get_playPressAfterConfirm():Bool
{
return Save?.instance?.options?.playPressAfterConfirm ?? true;
}

static function set_playPressAfterConfirm(value:Bool):Bool
{
var save:Save = Save.instance;
save.options.playPressAfterConfirm = value;
save.flush();
return value;
}



/**
* Whether some particularly fowl language is displayed.
* @default `true`
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class FlxAtlasSprite extends FlxAnimate
*/
public function playAnimation(id:String, restart:Bool = false, ignoreOther:Bool = false, ?loop:Bool = false):Void
{
if (loop == null) loop = false; // ???????????
if (loop == null) loop = false;

// Skip if not allowed to play animations.
if (!canPlayOtherAnims && !ignoreOther) return;
Expand Down
71 changes: 40 additions & 31 deletions source/funkin/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package funkin.play;

import flixel.addons.display.FlxPieDial;
import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.transition.Transition;
//import flixel.addons.transition.Transition;
import funkin.ui.transition.CustomTransition as Transition;
import flixel.FlxCamera;
import flixel.FlxObject;
import flixel.FlxState;
Expand All @@ -14,6 +15,7 @@ import flixel.text.FlxText;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.ui.FlxBar;
import funkin.ui.Bar;
import flixel.util.FlxColor;
import flixel.util.FlxTimer;
import funkin.api.newgrounds.NGio;
Expand Down Expand Up @@ -497,7 +499,7 @@ class PlayState extends MusicBeatSubState
* The bar which displays the player's health.
* Dynamically updated based on the value of `healthLerp` (which is based on `health`).
*/
public var healthBar:FlxBar;
public var healthBar:Bar;

/**
* The background image used for the health bar.
Expand Down Expand Up @@ -1371,15 +1373,9 @@ class PlayState extends MusicBeatSubState
#end

/**
* Removes any references to the current stage, then clears the stage cache,
* then reloads all the stages.
*
* This is useful for when you want to edit a stage without reloading the whole game.
* Reloading works on both the JSON and the HXC, if applicable.
*
* Call this by pressing F5 on a debug build.
*/
override function debug_refreshModules():Void
override function reloadAssets():Void
{
// Prevent further gameplay updates, which will try to reference dead objects.
criticalFailure = true;
Expand Down Expand Up @@ -1421,7 +1417,8 @@ class PlayState extends MusicBeatSubState
vocals.stop();
}

super.debug_refreshModules();

super.reloadAssets();

var event:ScriptEvent = new ScriptEvent(CREATE, false);
ScriptEventDispatcher.callEvent(currentSong, event);
Expand All @@ -1436,17 +1433,6 @@ class PlayState extends MusicBeatSubState

if (isGamePaused) return false;

/*if (!startingSong
&& FlxG.sound.music != null
&& (Math.abs(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 100 * playbackRate
|| Math.abs(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 100 * playbackRate))
{
trace("VOCALS NEED RESYNC");
if (vocals != null) trace(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
trace(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
resyncVocals();
}*/

if (iconP1 != null) iconP1.onStepHit(Std.int(Conductor.instance.currentStep));
if (iconP2 != null) iconP2.onStepHit(Std.int(Conductor.instance.currentStep));

Expand All @@ -1468,6 +1454,16 @@ class PlayState extends MusicBeatSubState
// activeNotes.sort(SortUtil.byStrumtime, FlxSort.DESCENDING);
}

if (!startingSong && FlxG.sound.music != null
&& (Math.abs(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 100
|| Math.abs(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 100))
{
trace("VOCALS NEED RESYNC");
if (vocals != null) trace(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
trace(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
resyncVocals();
}

// Only bop camera if zoom level is below 135%
if (Preferences.zoomCamera
&& FlxG.camera.zoom < (1.35 * FlxCamera.defaultZoom)
Expand Down Expand Up @@ -1586,20 +1582,29 @@ class PlayState extends MusicBeatSubState
dynamic function initHealthBar():Void
{
var healthBarYPos:Float = Preferences.downscroll ? FlxG.height * 0.1 : FlxG.height * 0.9;
healthBarBG = FunkinSprite.create(0, healthBarYPos, 'healthBar');
/*healthBarBG = FunkinSprite.create(0, healthBarYPos, 'healthBar');
healthBarBG.screenCenter(X);
healthBarBG.scrollFactor.set(0, 0);
healthBarBG.zIndex = 803;
add(healthBarBG);
add(healthBarBG);*/

healthBar = new FlxBar(healthBarBG.x + 4, healthBarBG.y + 4, RIGHT_TO_LEFT, Std.int(healthBarBG.width - 8), Std.int(healthBarBG.height - 8), this,
/*healthBar = new FlxBar(healthBarBG.x + 4, healthBarBG.y + 4, RIGHT_TO_LEFT, Std.int(healthBarBG.width - 8), Std.int(healthBarBG.height - 8), this,
'healthLerp', 0, 2);
healthBar.scrollFactor.set();
healthBar.createFilledBar(Constants.COLOR_HEALTH_BAR_RED, Constants.COLOR_HEALTH_BAR_GREEN);
healthBar.zIndex = 801;
healthBar.unbounded = true;
add(healthBar);
add(healthBar);*/

healthBar = new Bar(0, healthBarYPos, 'healthBar', () -> return healthLerp, 0, 2);
healthBarBG = healthBar.bg;
healthBar.smoothFactor = 1;
healthBar.scrollFactor.set();
healthBar.screenCenter(X);
healthBar.zIndex = 801;
healthBar.setColors(Constants.COLOR_HEALTH_BAR_RED, Constants.COLOR_HEALTH_BAR_GREEN);
add(healthBar);

// The score text below the health bar.
scoreText = new FlxText(healthBarBG.x + healthBarBG.width - 190, healthBarBG.y + 30, 0, '', 20);
scoreText.setFormat(Paths.font('vcr.ttf'), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
Expand Down Expand Up @@ -1986,6 +1991,8 @@ class PlayState extends MusicBeatSubState
if (vocals != null) vocals.stop();
vocals = currentChart.buildVocals();
add(vocals);
vocals.pause();
vocals.time = 0;

if (vocals.members.length == 0)
trace('WARNING: No vocals found for this song.');
Expand Down Expand Up @@ -2056,14 +2063,16 @@ class PlayState extends MusicBeatSubState
// Skip this if the music is paused (GameOver, Pause menu, start-of-song offset, etc.)
if (!FlxG.sound.music.playing) return;

FlxG.sound.music.pause();
var timeToPlayAt:Float = Conductor.instance.songPosition - Conductor.instance.instrumentalOffset;

FlxG.sound.music.pause();
vocals.pause();

FlxG.sound.music.time = Conductor.instance.songPosition;
FlxG.sound.music.play(false, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset);
FlxG.sound.music.time = timeToPlayAt;
FlxG.sound.music.play(false, timeToPlayAt);

vocals.time = Conductor.instance.songPosition;
vocals.play(false, Conductor.instance.songPosition);
vocals.time = timeToPlayAt;
vocals.play(false, timeToPlayAt);
}

/**
Expand All @@ -2086,7 +2095,7 @@ class PlayState extends MusicBeatSubState
{
final newDadColor = dadColor ?? ((iconP2 != null) ? iconP2.healthColor : Constants.COLOR_HEALTH_BAR_RED);
final newBfColor = bfColor ?? ((iconP1 != null) ? iconP1.healthColor : Constants.COLOR_HEALTH_BAR_GREEN);
healthBar.createFilledBar(newDadColor, newBfColor);
healthBar.setColors(newDadColor, newBfColor);
}

/**
Expand Down
64 changes: 23 additions & 41 deletions source/funkin/play/ResultState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ class ResultState extends MusicBeatSubState

heartsPerfect.anim.onComplete = () -> {
if (heartsPerfect != null)
{
// bfPerfect.anim.curFrame = 137;
heartsPerfect.anim.curFrame = 43;
heartsPerfect.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
heartsPerfect.anim.play("hearts full anim", true, false, 43); // unpauses this anim, since it's on PlayOnce!
};

bfPerfect = new FlxAtlasSprite(1342, 370, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT", "shared"));
Expand All @@ -181,11 +177,7 @@ class ResultState extends MusicBeatSubState

bfPerfect.anim.onComplete = () -> {
if (bfPerfect != null)
{
// bfPerfect.anim.curFrame = 137;
bfPerfect.anim.curFrame = 137;
bfPerfect.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
bfPerfect.anim.play("boyfriend perfect rank", true, false, 137); // unpauses this anim, since it's on PlayOnce!
};

case EXCELLENT:
Expand All @@ -196,10 +188,7 @@ class ResultState extends MusicBeatSubState

bfExcellent.anim.onComplete = () -> {
if (bfExcellent != null)
{
bfExcellent.anim.curFrame = 28;
bfExcellent.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
bfExcellent.anim.play("bf results excellent", true, false, 28); // unpauses this anim, since it's on PlayOnce!
};

case GREAT:
Expand All @@ -212,10 +201,7 @@ class ResultState extends MusicBeatSubState

gfGreat.anim.onComplete = () -> {
if (gfGreat != null)
{
gfGreat.anim.curFrame = 9;
gfGreat.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
gfGreat.anim.play("gf jumping", true, false, 9); // unpauses this anim, since it's on PlayOnce!
};

bfGreat = new FlxAtlasSprite(929, 363, Paths.animateAtlas("resultScreen/results-bf/resultsGREAT/bf", "shared"));
Expand All @@ -227,10 +213,7 @@ class ResultState extends MusicBeatSubState

bfGreat.anim.onComplete = () -> {
if (bfGreat != null)
{
bfGreat.anim.curFrame = 15;
bfGreat.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
bfGreat.anim.play("bf jumping ", true, false, 15); // unpauses this anim, since it's on PlayOnce!
};

case GOOD:
Expand Down Expand Up @@ -716,9 +699,7 @@ class ResultState extends MusicBeatSubState
add(clearPercentSmall);
clearPercentSmall.visible = true;
clearPercentSmall.flash(true);
new FlxTimer().start(0.4, _ -> {
clearPercentSmall.flash(false);
});
new FlxTimer().start(0.4, _ -> clearPercentSmall.flash(false));

clearPercentSmall.curNumber = clearPercentTarget;
clearPercentSmall.zIndex = 1000;
Expand Down Expand Up @@ -788,24 +769,25 @@ class ResultState extends MusicBeatSubState
trace('THE RANK IS Higher.....');

FlxTween.tween(rankBg, {alpha: 1}, 0.5,
{
ease: FlxEase.expoOut,
onComplete: function(_)
{
ease: FlxEase.expoOut,
onComplete: function(_) {
FlxG.switchState(FreeplayState.build(
FlxG.switchState(FreeplayState.build(
{
{
fromResults:
{
{
fromResults:
{
oldRank: Scoring.calculateRank(params?.prevScoreData),
newRank: rank,
songId: params.songId,
difficultyId: params.difficultyId,
playRankAnim: true
}
}
}));
}
});
oldRank: Scoring.calculateRank(params?.prevScoreData),
newRank: rank,
songId: params.songId,
difficultyId: params.difficultyId,
playRankAnim: true
}
}
}));
}
});
}
else
{
Expand Down
13 changes: 6 additions & 7 deletions source/funkin/play/components/HealthIcon.hx
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,19 @@ class HealthIcon extends FunkinSprite
// Update the animation based on the current state.
updateHealthIcon(PlayState.instance.health);
// Update the position to match the health bar.
this.x = PlayState.instance.healthBar.x
+ (PlayState.instance.healthBar.width * (FlxMath.remapToRange(PlayState.instance.healthBar.value, 0, 2, 100, 0) * 0.01) - POSITION_OFFSET);
this.x = PlayState.instance.healthBar.centerPoint.x - POSITION_OFFSET;
case 1: // Dad
// Update the animation based on the current state.
updateHealthIcon(MAXIMUM_HEALTH - PlayState.instance.health);
// Update the position to match the health bar.
this.x = PlayState.instance.healthBar.x
+ (PlayState.instance.healthBar.width * (FlxMath.remapToRange(PlayState.instance.healthBar.value, 0, 2, 100, 0) * 0.01))
- (this.width - POSITION_OFFSET);
this.x = PlayState.instance.healthBar.centerPoint.x - (this.width - POSITION_OFFSET);
}

// Keep the icon centered vertically on the health bar.
//this.y = PlayState.instance.healthBar.y - (this.height / 2); // - (PlayState.instance.healthBar.height / 2)
this.y = (PlayState.instance.healthBar.y + PlayState.instance.healthBar.height / 2) - (this.height / 2);
//this.y = PlayState.instance.healthBar.y - (this.height / 2); // - (PlayState.instance.healthBar.height / 2) oldest
//this.y = (PlayState.instance.healthBar.y + PlayState.instance.healthBar.height / 2) - (this.height / 2); old
this.y = PlayState.instance.healthBar.centerPoint.y - (this.height / 2);

}
}

Expand Down
Loading

0 comments on commit fdff812

Please sign in to comment.