1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-23 13:48:23 +00:00

wip sequence

This commit is contained in:
CheemsAndFriends 2024-09-06 02:55:47 +02:00
parent def2b64a41
commit 677357ba37
3 changed files with 111 additions and 55 deletions

View file

@ -388,7 +388,7 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
}
else
{
var music = FunkinSound.load(pathToUse, params?.startingVolume ?? 1.0, params.loop ?? true, false, true);
var music = FunkinSound.load(pathToUse, params?.startingVolume ?? 1.0, params.loop ?? true, false, true, params.onComplete);
if (music != null)
{
FlxG.sound.music = music;
@ -396,6 +396,8 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
// Prevent repeat update() and onFocus() calls.
FlxG.sound.list.remove(FlxG.sound.music);
if (FlxG.sound.music != null && params.onLoad != null) params.onLoad();
return true;
}
else

View file

@ -21,7 +21,7 @@ class CharSelectPlayer extends FlxAtlasSprite
if (hasAnimation("slidein idle point")) playAnimation("slidein idle point", true, false, false);
else
playAnimation("idle", true, false, true);
case "slidein idle point":
case "slidein idle point", "cannot select", "unlock":
playAnimation("idle", true, false, true);
}
});

View file

@ -26,6 +26,7 @@ import funkin.ui.PixelatedIcon;
import funkin.util.MathUtil;
import funkin.vis.dsp.SpectralAnalyzer;
import openfl.display.BlendMode;
import funkin.save.Save;
class CharSelectSubState extends MusicBeatSubState
{
@ -69,8 +70,6 @@ class CharSelectSubState extends MusicBeatSubState
var charSelectCam:FunkinCamera;
var introM:FunkinSound = null;
public function new()
{
super();
@ -89,6 +88,8 @@ class CharSelectSubState extends MusicBeatSubState
var playerData = player.getCharSelectData();
if (playerData == null) continue;
trace(player.isUnlocked());
var targetPosition:Int = playerData.position ?? 0;
while (availableChars.exists(targetPosition))
{
@ -104,38 +105,6 @@ class CharSelectSubState extends MusicBeatSubState
{
super.create();
selectSound = new FunkinSound();
selectSound.loadEmbedded(Paths.sound('CS_select'));
selectSound.pitch = 1;
selectSound.volume = 0.7;
FlxG.sound.defaultSoundGroup.add(selectSound);
// playing it here to preload it. not doing this makes a super awkward pause at the end of the intro
// TODO: probably make an intro thing for funkinSound itself that preloads the next audio?
FunkinSound.playMusic('stayFunky',
{
startingVolume: 0,
overrideExisting: true,
restartTrack: true
});
var introMusic:String = Paths.music('stayFunky/stayFunky-intro');
introM = FunkinSound.load(introMusic, 1.0, false, true, true, () -> {
FunkinSound.playMusic('stayFunky',
{
startingVolume: 1,
overrideExisting: true,
restartTrack: true
});
@:privateAccess
gfChill.analyzer = new SpectralAnalyzer(FlxG.sound.music._channel.__audioSource, 7, 0.1);
#if desktop
// On desktop it uses FFT stuff that isn't as optimized as the direct browser stuff we use on HTML5
// So we want to manually change it!
@:privateAccess
gfChill.analyzer.fftN = 512;
#end
});
var bg:FlxSprite = new FlxSprite(-153, -140);
bg.loadGraphic(Paths.image('charSelect/charSelectBG'));
bg.scrollFactor.set(0.1, 0.1);
@ -174,15 +143,15 @@ class CharSelectSubState extends MusicBeatSubState
gfChill = new CharSelectGF();
gfChill.switchGF("bf");
add(gfChill);
@:privateAccess
playerChill = new CharSelectPlayer(0, 0);
playerChill.switchChar("bf");
add(playerChill);
playerChillOut = new CharSelectPlayer(0, 0);
playerChillOut.switchChar("bf");
add(playerChillOut);
playerChill = new CharSelectPlayer(0, 0);
playerChill.switchChar("bf");
add(playerChill);
var speakers:FlxAtlasSprite = new FlxAtlasSprite(0, 0, Paths.animateAtlas("charSelect/charSelectSpeakers"));
speakers.anim.play("");
speakers.scrollFactor.set(1.8, 1.8);
@ -289,7 +258,7 @@ class CharSelectSubState extends MusicBeatSubState
FlxG.debugger.addTrackerProfile(new TrackerProfile(CharSelectSubState, ["curChar", "grpXSpread", "grpYSpread"]));
FlxG.debugger.track(this);
FlxG.sound.playMusic(Paths.music('charSelect/charSelectMusic'));
// FlxG.sound.playMusic(Paths.music('charSelect/charSelectMusic'));
camFollow = new FlxObject(0, 0, 1, 1);
add(camFollow);
@ -301,6 +270,14 @@ class CharSelectSubState extends MusicBeatSubState
temp.loadGraphic(Paths.image('charSelect/placement'));
add(temp);
temp.alpha = 0.0;
selectSound = new FunkinSound();
selectSound.loadEmbedded(Paths.sound('CS_select'));
selectSound.pitch = 1;
selectSound.volume = 0.7;
FlxG.sound.defaultSoundGroup.add(selectSound);
Conductor.stepHit.add(spamOnStep);
// FlxG.debugger.track(temp, "tempBG");
}
@ -309,6 +286,8 @@ class CharSelectSubState extends MusicBeatSubState
var grpXSpread(default, set):Float = 107;
var grpYSpread(default, set):Float = 127;
var nonLocks = [];
function initLocks():Void
{
grpIcons = new FlxSpriteGroup();
@ -319,7 +298,7 @@ class CharSelectSubState extends MusicBeatSubState
for (i in 0...9)
{
if (availableChars.exists(i))
if (availableChars.exists(i) && Save.instance.charactersSeen.contains(availableChars[i]))
{
var path:String = availableChars.get(i);
var temp:PixelatedIcon = new PixelatedIcon(0, 0);
@ -331,9 +310,15 @@ class CharSelectSubState extends MusicBeatSubState
}
else
{
if (availableChars.exists(i)) nonLocks.push(i);
var temp:Lock = new Lock(0, 0, i);
temp.ID = 1;
temp.onAnimationComplete.add(function(anim) {
if (anim == "unlock") playerChill.playAnimation("unlock", true);
});
grpIcons.add(temp);
}
}
@ -341,6 +326,78 @@ class CharSelectSubState extends MusicBeatSubState
updateIconPositions();
grpIcons.scrollFactor.set();
// playing it here to preload it. not doing this makes a super awkward pause at the end of the intro
// TODO: probably make an intro thing for funkinSound itself that preloads the next audio?
FunkinSound.playMusic('stayFunky',
{
startingVolume: 0,
overrideExisting: true,
restartTrack: true,
});
unLock();
}
function unLock()
{
var index = nonLocks[0];
var copy = 3;
var yThing = 0;
while (index > copy)
{
yThing++;
copy += 3;
}
var xThing = copy - index - 1;
cursorY = 3 - yThing;
cursorX = 3 - xThing;
selectTimer.start(1, function(_) {
var lock:Lock = cast grpIcons.group.members[index];
lock.playAnimation("unlock");
playerChill.visible = false;
playerChill.switchChar(availableChars[index]);
playerChillOut.visible = true;
playerChillOut.playAnimation("death");
playerChillOut.onAnimationComplete.addOnce((_) -> if (_ == "death")
{
playerChill.playAnimation("unlock");
playerChill.onAnimationComplete.addOnce(function(_) {
nonLocks.shift();
if (nonLocks.length > 0) unLock();
else
{
FunkinSound.playMusic('stayFunky',
{
startingVolume: 1,
overrideExisting: true,
restartTrack: true,
onLoad: function() {
@:privateAccess
gfChill.analyzer = new SpectralAnalyzer(FlxG.sound.music._channel.__audioSource, 7, 0.1);
#if desktop
// On desktop it uses FFT stuff that isn't as optimized as the direct browser stuff we use on HTML5
// So we want to manually change it!
@:privateAccess
gfChill.analyzer.fftN = 512;
#end
}
});
}
});
playerChill.visible = true;
});
});
}
function updateIconPositions()
@ -372,17 +429,6 @@ class CharSelectSubState extends MusicBeatSubState
override public function update(elapsed:Float):Void
{
super.update(elapsed);
@:privateAccess
if (introM != null && !introM.paused && gfChill.analyzer == null)
{
gfChill.analyzer = new SpectralAnalyzer(introM._channel.__audioSource, 7, 0.1);
#if desktop
// On desktop it uses FFT stuff that isn't as optimized as the direct browser stuff we use on HTML5
// So we want to manually change it!
@:privateAccess
gfChill.analyzer.fftN = 512;
#end
}
Conductor.instance.update();
@ -426,6 +472,8 @@ class CharSelectSubState extends MusicBeatSubState
if (controls.UI_UP_P)
{
cursorY -= 1;
cursorDenied.visible = false;
holdTmrUp = 0;
selectSound.play(true);
@ -433,18 +481,22 @@ class CharSelectSubState extends MusicBeatSubState
if (controls.UI_DOWN_P)
{
cursorY += 1;
cursorDenied.visible = false;
holdTmrDown = 0;
selectSound.play(true);
}
if (controls.UI_LEFT_P)
{
cursorX -= 1;
cursorDenied.visible = false;
holdTmrLeft = 0;
selectSound.play(true);
}
if (controls.UI_RIGHT_P)
{
cursorX += 1;
cursorDenied.visible = false;
holdTmrRight = 0;
selectSound.play(true);
}
@ -466,7 +518,7 @@ class CharSelectSubState extends MusicBeatSubState
cursorY = -1;
}
if (availableChars.exists(getCurrentSelected()))
if (availableChars.exists(getCurrentSelected()) && Save.instance.charactersSeen.contains(availableChars[getCurrentSelected()]))
{
curChar = availableChars.get(getCurrentSelected());
@ -567,6 +619,8 @@ class CharSelectSubState extends MusicBeatSubState
if (selectSound.pitch > 5) selectSound.pitch = 5;
selectSound.play(true);
cursorDenied.visible = false;
if (spamUp)
{
cursorY -= 1;
@ -621,7 +675,7 @@ class CharSelectSubState extends MusicBeatSubState
memb.scale.set(2.6, 2.6);
if (controls.ACCEPT) memb.animation.play("confirm");
if (controls.BACK)
if (memb.animation.curAnim.name == "confirm" && controls.BACK)
{
memb.animation.play("confirm", false, true);
member.animation.finishCallback = (_) -> {