mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-15 11:22:55 +00:00
initial Commit
This commit is contained in:
parent
94a08ff528
commit
7f0f0efe46
2
assets
2
assets
|
@ -1 +1 @@
|
|||
Subproject commit 0e4392bcb0ed1dbb496764cff074635c20c91389
|
||||
Subproject commit 299f5ac20fd9ee50fda5cadd6abb22b68d86fb87
|
|
@ -182,6 +182,7 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
trace('Playing animation $id');
|
||||
this.anim.play(id, restart, false, startFrame);
|
||||
goToFrameLabel(id);
|
||||
anim.curFrame += startFrame;
|
||||
this.currentAnimation = id;
|
||||
}
|
||||
|
||||
|
@ -301,7 +302,7 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
|
||||
public function getBasePosition():Null<FlxPoint>
|
||||
{
|
||||
var stagePos = new FlxPoint(anim.stageInstance.matrix.tx, anim.stageInstance.matrix.ty);
|
||||
// var stagePos = new FlxPoint(anim.stageInstance.matrix.tx, anim.stageInstance.matrix.ty);
|
||||
var instancePos = new FlxPoint(anim.curInstance.matrix.tx, anim.curInstance.matrix.ty);
|
||||
var firstElement = anim.curSymbol.timeline?.get(0)?.get(0)?.get(0);
|
||||
if (firstElement == null) return instancePos;
|
||||
|
|
|
@ -8,6 +8,7 @@ import funkin.util.FramesJSFLParser;
|
|||
import funkin.util.FramesJSFLParser.FramesJSFLInfo;
|
||||
import funkin.util.FramesJSFLParser.FramesJSFLFrame;
|
||||
import flixel.math.FlxMath;
|
||||
import funkin.vis.dsp.SpectralAnalyzer;
|
||||
|
||||
class CharSelectGF extends FlxAtlasSprite
|
||||
{
|
||||
|
@ -20,14 +21,47 @@ class CharSelectGF extends FlxAtlasSprite
|
|||
|
||||
var intendedYPos:Float = 0;
|
||||
var intendedAlpha:Float = 0;
|
||||
var list:Array<String> = [];
|
||||
var char:String = "gf";
|
||||
|
||||
var analyzer:SpectralAnalyzer;
|
||||
|
||||
public function new()
|
||||
{
|
||||
super(0, 0, Paths.animateAtlas("charSelect/gfChill"));
|
||||
anim.play("");
|
||||
list = anim.curSymbol.getFrameLabelNames();
|
||||
|
||||
switchGF("bf");
|
||||
}
|
||||
|
||||
var _addedCallback:String = "";
|
||||
|
||||
override public function playAnimation(id:String, restart:Bool = false, ignoreOther:Bool = false, loop:Bool = false, startFrame:Int = 0):Void
|
||||
{
|
||||
if (id == null) id = "idle";
|
||||
// var fr = anim.getFrameLabel("confirm");
|
||||
// fr.removeCallbacks();
|
||||
// fr.add(() -> trace("HEY"));
|
||||
|
||||
if (id != _addedCallback)
|
||||
{
|
||||
var next = list[list.indexOf(_addedCallback) + 1];
|
||||
if (next != null) anim.getFrameLabel(next).removeCallbacks();
|
||||
|
||||
var index:Int = list.indexOf(id);
|
||||
|
||||
_addedCallback = list[index];
|
||||
if (index != -1 && index + 1 < list.length)
|
||||
{
|
||||
var lb = anim.getFrameLabel(list[index + 1]);
|
||||
@:privateAccess
|
||||
lb.add(() -> playAnimation(list[index], true, false, false));
|
||||
}
|
||||
}
|
||||
super.playAnimation(id, restart, ignoreOther, loop, startFrame);
|
||||
}
|
||||
|
||||
override public function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
@ -59,6 +93,39 @@ class CharSelectGF extends FlxAtlasSprite
|
|||
}
|
||||
}
|
||||
|
||||
override public function draw()
|
||||
{
|
||||
if (analyzer != null) drawFFT();
|
||||
super.draw();
|
||||
}
|
||||
|
||||
function drawFFT()
|
||||
{
|
||||
if (char == "nene")
|
||||
{
|
||||
var levels = analyzer.getLevels();
|
||||
var frame = anim.curSymbol.timeline.get("VIZ_bars").get(anim.curFrame);
|
||||
var elements = frame.getList();
|
||||
var len:Int = cast Math.min(elements.length, 7);
|
||||
|
||||
for (i in 0...len)
|
||||
{
|
||||
var animFrame:Int = Math.round(levels[i].value * 12);
|
||||
|
||||
#if desktop
|
||||
animFrame = Math.round(animFrame * FlxG.sound.volume);
|
||||
#end
|
||||
|
||||
animFrame = Math.floor(Math.min(12, animFrame));
|
||||
animFrame = Math.floor(Math.max(0, animFrame));
|
||||
|
||||
animFrame = Std.int(Math.abs(animFrame - 12)); // shitty dumbass flip, cuz dave got da shit backwards lol!
|
||||
|
||||
elements[i].symbol.firstFrame = animFrame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param animInfo Should not be confused with animInInfo!
|
||||
* This is merely a local var for the function!
|
||||
|
@ -113,6 +180,7 @@ class CharSelectGF extends FlxAtlasSprite
|
|||
"gf";
|
||||
}
|
||||
|
||||
char = str;
|
||||
switch str
|
||||
{
|
||||
default:
|
||||
|
@ -123,7 +191,8 @@ class CharSelectGF extends FlxAtlasSprite
|
|||
animOutInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/" + str + "AnimInfo/" + str + "Out.txt"));
|
||||
|
||||
anim.play("");
|
||||
playAnimation("idle", true, false, true);
|
||||
playAnimation("idle", true, false, false);
|
||||
addFrameCallback(getNextFrameLabel("idle"), () -> playAnimation("idle", true, false, false));
|
||||
|
||||
updateHitbox();
|
||||
}
|
||||
|
|
|
@ -10,22 +10,76 @@ class CharSelectPlayer extends FlxAtlasSprite
|
|||
super(x, y, Paths.animateAtlas("charSelect/bfChill"));
|
||||
|
||||
onAnimationComplete.add(function(animLabel:String) {
|
||||
switch (animLabel)
|
||||
{
|
||||
case "slidein":
|
||||
if (hasAnimation("slidein idle point")) playAnimation("slidein idle point", true, false, false);
|
||||
else
|
||||
playAnimation("idle", true, false, true);
|
||||
case "slidein idle point":
|
||||
playAnimation("idle", true, false, true);
|
||||
case "select":
|
||||
anim.pause();
|
||||
case "deselect":
|
||||
playAnimation("deselect loop start", true, false, true);
|
||||
}
|
||||
playAnimation("idle");
|
||||
});
|
||||
}
|
||||
|
||||
var _addedCall = false;
|
||||
|
||||
override public function playAnimation(id:String, restart:Bool = false, ignoreOther:Bool = false, loop:Bool = false, startFrame:Int = 0):Void
|
||||
{
|
||||
if (id == null || id == "") id = "idle";
|
||||
switch (id)
|
||||
{
|
||||
case "idle", "slidein idle point":
|
||||
if (!_addedCall)
|
||||
{
|
||||
var fr = anim.getFrameLabel("idle end");
|
||||
if (fr != null) fr.add(() -> {
|
||||
playAnimation("idle", true, false, false);
|
||||
});
|
||||
}
|
||||
_addedCall = true;
|
||||
|
||||
case "select":
|
||||
if (_addedCall)
|
||||
{
|
||||
anim.getFrameLabel("idle end").removeCallbacks();
|
||||
_addedCall = false;
|
||||
}
|
||||
|
||||
var fr = anim.getFrameLabel("deselect");
|
||||
|
||||
fr.add(() -> {
|
||||
anim.pause();
|
||||
anim.curFrame--;
|
||||
});
|
||||
|
||||
_addedCall = true;
|
||||
|
||||
case "deselect":
|
||||
var og = anim.getFrameLabel("deselect");
|
||||
if (_addedCall)
|
||||
{
|
||||
og.removeCallbacks();
|
||||
_addedCall = false;
|
||||
}
|
||||
|
||||
var fr = anim.getFrameLabel("deselect loop end");
|
||||
|
||||
fr.removeCallbacks();
|
||||
fr.add(() -> playAnimation("deselect loop start", true, false, false));
|
||||
|
||||
_addedCall = true;
|
||||
|
||||
case "slidein", "slideout":
|
||||
if (_addedCall)
|
||||
{
|
||||
anim.getFrameLabel("deselect loop end").removeCallbacks();
|
||||
_addedCall = false;
|
||||
}
|
||||
default:
|
||||
if (_addedCall)
|
||||
{
|
||||
anim.getFrameLabel("idle end").removeCallbacks();
|
||||
_addedCall = false;
|
||||
}
|
||||
}
|
||||
super.playAnimation(id, restart, ignoreOther, loop, startFrame);
|
||||
}
|
||||
|
||||
public function updatePosition(str:String)
|
||||
{
|
||||
switch (str)
|
||||
|
@ -48,7 +102,6 @@ class CharSelectPlayer extends FlxAtlasSprite
|
|||
loadAtlas(Paths.animateAtlas("charSelect/" + str + "Chill"));
|
||||
}
|
||||
|
||||
anim.play("");
|
||||
playAnimation("slidein", true, false, false);
|
||||
|
||||
updateHitbox();
|
||||
|
|
|
@ -22,6 +22,8 @@ import flixel.util.FlxTimer;
|
|||
import flixel.tweens.FlxEase;
|
||||
import flixel.sound.FlxSound;
|
||||
import funkin.audio.FunkinSound;
|
||||
import funkin.graphics.FunkinCamera;
|
||||
import funkin.vis.dsp.SpectralAnalyzer;
|
||||
|
||||
class CharSelectSubState extends MusicBeatSubState
|
||||
{
|
||||
|
@ -63,6 +65,10 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
var selectTimer:FlxTimer = new FlxTimer();
|
||||
var selectSound:FunkinSound;
|
||||
|
||||
var charSelectCam:FunkinCamera;
|
||||
|
||||
var introM:FunkinSound = null;
|
||||
|
||||
public function new()
|
||||
{
|
||||
super();
|
||||
|
@ -90,13 +96,21 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
restartTrack: true
|
||||
});
|
||||
var introMusic:String = Paths.music('stayFunky/stayFunky-intro');
|
||||
FunkinSound.load(introMusic, 1.0, false, true, true, () -> {
|
||||
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);
|
||||
|
@ -137,7 +151,7 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
gfChill = new CharSelectGF();
|
||||
gfChill.switchGF("bf");
|
||||
add(gfChill);
|
||||
|
||||
@:privateAccess
|
||||
playerChill = new CharSelectPlayer(0, 0);
|
||||
playerChill.switchChar("bf");
|
||||
add(playerChill);
|
||||
|
@ -349,6 +363,17 @@ 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();
|
||||
|
||||
|
@ -449,6 +474,7 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
|
||||
FlxTween.tween(FlxG.sound.music, {pitch: 0.1}, 1.5, {ease: FlxEase.quadInOut});
|
||||
playerChill.playAnimation("select");
|
||||
gfChill.playAnimation("confirm");
|
||||
pressedSelect = true;
|
||||
selectTimer.start(1.5, (_) -> {
|
||||
pressedSelect = false;
|
||||
|
@ -467,8 +493,20 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
grpCursors.visible = true;
|
||||
|
||||
FlxTween.globalManager.cancelTweensOf(FlxG.sound.music);
|
||||
FlxTween.tween(FlxG.sound.music, {pitch: 1.0}, 1, {ease: FlxEase.quartInOut});
|
||||
playerChill.playAnimation("deselect");
|
||||
gfChill.playAnimation("deselect");
|
||||
FlxTween.tween(FlxG.sound.music, {pitch: 1.0}, 1,
|
||||
{
|
||||
ease: FlxEase.quartInOut,
|
||||
onComplete: (_) -> {
|
||||
var fr = playerChill.anim.getFrameLabel("deselect loop end");
|
||||
if (fr != null) fr.removeCallbacks();
|
||||
@:privateAccess
|
||||
playerChill._addedCall = false;
|
||||
playerChill.playAnimation("idle");
|
||||
gfChill.playAnimation("idle");
|
||||
}
|
||||
});
|
||||
pressedSelect = false;
|
||||
selectTimer.cancel();
|
||||
}
|
||||
|
@ -572,6 +610,14 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
memb.scale.set(2.6, 2.6);
|
||||
|
||||
if (controls.ACCEPT) memb.animation.play("confirm");
|
||||
if (controls.BACK)
|
||||
{
|
||||
memb.animation.play("confirm", false, true);
|
||||
member.animation.finishCallback = (_) -> {
|
||||
member.animation.play("idle");
|
||||
member.animation.finishCallback = null;
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue