1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 19:33:36 +00:00

initial Commit

This commit is contained in:
CheemsAndFriends 2024-08-22 23:36:43 +02:00
parent 94a08ff528
commit 7f0f0efe46
5 changed files with 189 additions and 20 deletions

2
assets

@ -1 +1 @@
Subproject commit 0e4392bcb0ed1dbb496764cff074635c20c91389 Subproject commit 299f5ac20fd9ee50fda5cadd6abb22b68d86fb87

View file

@ -182,6 +182,7 @@ class FlxAtlasSprite extends FlxAnimate
trace('Playing animation $id'); trace('Playing animation $id');
this.anim.play(id, restart, false, startFrame); this.anim.play(id, restart, false, startFrame);
goToFrameLabel(id); goToFrameLabel(id);
anim.curFrame += startFrame;
this.currentAnimation = id; this.currentAnimation = id;
} }
@ -301,7 +302,7 @@ class FlxAtlasSprite extends FlxAnimate
public function getBasePosition():Null<FlxPoint> 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 instancePos = new FlxPoint(anim.curInstance.matrix.tx, anim.curInstance.matrix.ty);
var firstElement = anim.curSymbol.timeline?.get(0)?.get(0)?.get(0); var firstElement = anim.curSymbol.timeline?.get(0)?.get(0)?.get(0);
if (firstElement == null) return instancePos; if (firstElement == null) return instancePos;

View file

@ -8,6 +8,7 @@ import funkin.util.FramesJSFLParser;
import funkin.util.FramesJSFLParser.FramesJSFLInfo; import funkin.util.FramesJSFLParser.FramesJSFLInfo;
import funkin.util.FramesJSFLParser.FramesJSFLFrame; import funkin.util.FramesJSFLParser.FramesJSFLFrame;
import flixel.math.FlxMath; import flixel.math.FlxMath;
import funkin.vis.dsp.SpectralAnalyzer;
class CharSelectGF extends FlxAtlasSprite class CharSelectGF extends FlxAtlasSprite
{ {
@ -20,14 +21,47 @@ class CharSelectGF extends FlxAtlasSprite
var intendedYPos:Float = 0; var intendedYPos:Float = 0;
var intendedAlpha:Float = 0; var intendedAlpha:Float = 0;
var list:Array<String> = [];
var char:String = "gf";
var analyzer:SpectralAnalyzer;
public function new() public function new()
{ {
super(0, 0, Paths.animateAtlas("charSelect/gfChill")); super(0, 0, Paths.animateAtlas("charSelect/gfChill"));
anim.play(""); anim.play("");
list = anim.curSymbol.getFrameLabelNames();
switchGF("bf"); 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) override public function update(elapsed:Float)
{ {
super.update(elapsed); 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! * @param animInfo Should not be confused with animInInfo!
* This is merely a local var for the function! * This is merely a local var for the function!
@ -113,6 +180,7 @@ class CharSelectGF extends FlxAtlasSprite
"gf"; "gf";
} }
char = str;
switch str switch str
{ {
default: default:
@ -123,7 +191,8 @@ class CharSelectGF extends FlxAtlasSprite
animOutInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/" + str + "AnimInfo/" + str + "Out.txt")); animOutInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/" + str + "AnimInfo/" + str + "Out.txt"));
anim.play(""); anim.play("");
playAnimation("idle", true, false, true); playAnimation("idle", true, false, false);
addFrameCallback(getNextFrameLabel("idle"), () -> playAnimation("idle", true, false, false));
updateHitbox(); updateHitbox();
} }

View file

@ -10,22 +10,76 @@ class CharSelectPlayer extends FlxAtlasSprite
super(x, y, Paths.animateAtlas("charSelect/bfChill")); super(x, y, Paths.animateAtlas("charSelect/bfChill"));
onAnimationComplete.add(function(animLabel:String) { onAnimationComplete.add(function(animLabel:String) {
switch (animLabel)
{
case "slidein":
if (hasAnimation("slidein idle point")) playAnimation("slidein idle point", true, false, false); if (hasAnimation("slidein idle point")) playAnimation("slidein idle point", true, false, false);
else else
playAnimation("idle", true, false, true); playAnimation("idle");
case "slidein idle point":
playAnimation("idle", true, false, true);
case "select":
anim.pause();
case "deselect":
playAnimation("deselect loop start", true, false, true);
}
}); });
} }
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) public function updatePosition(str:String)
{ {
switch (str) switch (str)
@ -48,7 +102,6 @@ class CharSelectPlayer extends FlxAtlasSprite
loadAtlas(Paths.animateAtlas("charSelect/" + str + "Chill")); loadAtlas(Paths.animateAtlas("charSelect/" + str + "Chill"));
} }
anim.play("");
playAnimation("slidein", true, false, false); playAnimation("slidein", true, false, false);
updateHitbox(); updateHitbox();

View file

@ -22,6 +22,8 @@ import flixel.util.FlxTimer;
import flixel.tweens.FlxEase; import flixel.tweens.FlxEase;
import flixel.sound.FlxSound; import flixel.sound.FlxSound;
import funkin.audio.FunkinSound; import funkin.audio.FunkinSound;
import funkin.graphics.FunkinCamera;
import funkin.vis.dsp.SpectralAnalyzer;
class CharSelectSubState extends MusicBeatSubState class CharSelectSubState extends MusicBeatSubState
{ {
@ -63,6 +65,10 @@ class CharSelectSubState extends MusicBeatSubState
var selectTimer:FlxTimer = new FlxTimer(); var selectTimer:FlxTimer = new FlxTimer();
var selectSound:FunkinSound; var selectSound:FunkinSound;
var charSelectCam:FunkinCamera;
var introM:FunkinSound = null;
public function new() public function new()
{ {
super(); super();
@ -90,13 +96,21 @@ class CharSelectSubState extends MusicBeatSubState
restartTrack: true restartTrack: true
}); });
var introMusic:String = Paths.music('stayFunky/stayFunky-intro'); 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', FunkinSound.playMusic('stayFunky',
{ {
startingVolume: 1, startingVolume: 1,
overrideExisting: true, overrideExisting: true,
restartTrack: 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); var bg:FlxSprite = new FlxSprite(-153, -140);
@ -137,7 +151,7 @@ class CharSelectSubState extends MusicBeatSubState
gfChill = new CharSelectGF(); gfChill = new CharSelectGF();
gfChill.switchGF("bf"); gfChill.switchGF("bf");
add(gfChill); add(gfChill);
@:privateAccess
playerChill = new CharSelectPlayer(0, 0); playerChill = new CharSelectPlayer(0, 0);
playerChill.switchChar("bf"); playerChill.switchChar("bf");
add(playerChill); add(playerChill);
@ -349,6 +363,17 @@ class CharSelectSubState extends MusicBeatSubState
override public function update(elapsed:Float):Void override public function update(elapsed:Float):Void
{ {
super.update(elapsed); 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(); Conductor.instance.update();
@ -449,6 +474,7 @@ class CharSelectSubState extends MusicBeatSubState
FlxTween.tween(FlxG.sound.music, {pitch: 0.1}, 1.5, {ease: FlxEase.quadInOut}); FlxTween.tween(FlxG.sound.music, {pitch: 0.1}, 1.5, {ease: FlxEase.quadInOut});
playerChill.playAnimation("select"); playerChill.playAnimation("select");
gfChill.playAnimation("confirm");
pressedSelect = true; pressedSelect = true;
selectTimer.start(1.5, (_) -> { selectTimer.start(1.5, (_) -> {
pressedSelect = false; pressedSelect = false;
@ -467,8 +493,20 @@ class CharSelectSubState extends MusicBeatSubState
grpCursors.visible = true; grpCursors.visible = true;
FlxTween.globalManager.cancelTweensOf(FlxG.sound.music); FlxTween.globalManager.cancelTweensOf(FlxG.sound.music);
FlxTween.tween(FlxG.sound.music, {pitch: 1.0}, 1, {ease: FlxEase.quartInOut});
playerChill.playAnimation("deselect"); 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; pressedSelect = false;
selectTimer.cancel(); selectTimer.cancel();
} }
@ -572,6 +610,14 @@ class CharSelectSubState extends MusicBeatSubState
memb.scale.set(2.6, 2.6); memb.scale.set(2.6, 2.6);
if (controls.ACCEPT) memb.animation.play("confirm"); 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 else
{ {