1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-11-26 06:09:02 +00:00

Add a buncho Gizmos

This commit is contained in:
CheemsAndFriends 2024-09-09 08:23:46 +02:00
parent f3722e5da2
commit 6961e6cc63
11 changed files with 174 additions and 37 deletions

2
art

@ -1 +1 @@
Subproject commit faeba700c5526bd4fd57ccc927d875c82b9d3553 Subproject commit e2663c1cbe029f04a98500735943f0b9465548bf

2
assets

@ -1 +1 @@
Subproject commit d2ea072f32d0ba74cf8c62576f28e7b03d591ddb Subproject commit c6a2a13d754e3566d25e762acec3a74e7116f23e

View file

@ -37,7 +37,6 @@ import openfl.display._internal.CairoGraphics as GfxRenderer;
/** /**
* A modified `FlxSprite` that supports filters. * A modified `FlxSprite` that supports filters.
* The name's pretty much self-explanatory. * The name's pretty much self-explanatory.
* @author CheemsAndFriends
*/ */
@:access(openfl.geom.Rectangle) @:access(openfl.geom.Rectangle)
@:access(openfl.filters.BitmapFilter) @:access(openfl.filters.BitmapFilter)
@ -146,7 +145,7 @@ class FlxFilteredSprite extends FlxSprite
_matrix.ty = Math.floor(_matrix.ty); _matrix.ty = Math.floor(_matrix.ty);
} }
camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing, shader); camera.drawPixels((filtered) ? _blankFrame : _frame, framePixels, _matrix, colorTransform, blend, antialiasing, shader);
} }
@:noCompletion @:noCompletion
@ -154,7 +153,6 @@ class FlxFilteredSprite extends FlxSprite
{ {
filterDirty = false; filterDirty = false;
_filterMatrix.identity(); _filterMatrix.identity();
var filteredFrame = (filtered) ? _frame : null;
if (filters != null && filters.length > 0) if (filters != null && filters.length > 0)
{ {
@ -195,6 +193,7 @@ class FlxFilteredSprite extends FlxSprite
} }
else else
{ {
trace("GAGAGA");
resetFrame(); resetFrame();
filtered = false; filtered = false;
} }
@ -215,6 +214,11 @@ class FlxFilteredSprite extends FlxSprite
return super.set_frame(value); return super.set_frame(value);
} }
override public function destroy()
{
super.destroy();
}
} }
@:noCompletion @:noCompletion
@ -339,6 +343,15 @@ class FlxAnimateFilterRenderer
if (target1 == null) bitmap2.dispose(); if (target1 == null) bitmap2.dispose();
if (target2 == null) bitmap3.dispose(); if (target2 == null) bitmap3.dispose();
// var gl = renderer.__gl;
// var renderBuffer = bitmap.getTexture(renderer.__context3D);
// @:privateAccess
// gl.readPixels(0, 0, bitmap.width, bitmap.height, renderBuffer.__format, gl.UNSIGNED_BYTE, bitmap.image.data);
// bitmap.image.version = 0;
// @:privateAccess
// bitmap.__textureVersion = -1;
return bitmap; return bitmap;
} }

View file

@ -217,6 +217,9 @@ class FlxAtlasSprite extends FlxAnimate
{ {
if (this.anim == null) return false; if (this.anim == null) return false;
if (!this.anim.isPlaying) return false; if (!this.anim.isPlaying) return false;
if (fr != null) return (anim.reversed && anim.curFrame < fr.index || !anim.reversed && anim.curFrame >= (fr.index + fr.duration));
return (anim.reversed && anim.curFrame == 0 || !(anim.reversed) && (anim.curFrame) >= (anim.length - 1)); return (anim.reversed && anim.curFrame == 0 || !(anim.reversed) && (anim.curFrame) >= (anim.length - 1));
} }
@ -283,7 +286,7 @@ class FlxAtlasSprite extends FlxAnimate
{ {
onAnimationFrame.dispatch(currentAnimation, frame); onAnimationFrame.dispatch(currentAnimation, frame);
if (fr != null && frame > (fr.index + fr.duration - 1) || isLoopComplete()) if (isLoopComplete())
{ {
anim.pause(); anim.pause();
_onAnimationComplete(); _onAnimationComplete();

View file

@ -412,7 +412,7 @@ class Save
*/ */
public function addCharacterSeen(character:String):Void public function addCharacterSeen(character:String):Void
{ {
data.unlocks.charactersSeen.push(character); if (!data.unlocks.charactersSeen.contains(character)) data.unlocks.charactersSeen.push(character);
} }
/** /**

View file

@ -133,7 +133,7 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass
fadeTimer += FlxG.elapsed; fadeTimer += FlxG.elapsed;
if (fadeTimer >= 1 / 24) if (fadeTimer >= 1 / 24)
{ {
fadeTimer = 0; fadeTimer -= FlxG.elapsed;
// only inc the index for the first frame, used for reference of where to "start" // only inc the index for the first frame, used for reference of where to "start"
if (fadeAnimIndex == 0) if (fadeAnimIndex == 0)
{ {

View file

@ -26,19 +26,17 @@ class CharSelectPlayer extends FlxAtlasSprite implements IBPMSyncedScriptedClass
} }
else else
{ {
playAnimation("idle", true, false, true); playAnimation("idle", true, false, false);
} }
case "deselect":
playAnimation("deselect loop start", true, false, true);
case "slidein idle point", "cannot select", "unlock": case "slidein idle point", "cannot select", "unlock":
playAnimation("idle", true, false, true); playAnimation("idle", true, false, false);
case "idle": case "idle":
trace('Waiting for onBeatHit'); trace('Waiting for onBeatHit');
} }
}); });
onAnimationFrame.add(function(animLabel:String, frame:Int) {
if (animLabel == "deselect" && desLp != null && frame >= desLp.index) playAnimation("deselect loop start", true, false, true);
});
} }
public function onStepHit(event:SongTimeScriptEvent):Void {} public function onStepHit(event:SongTimeScriptEvent):Void {}
@ -50,6 +48,7 @@ class CharSelectPlayer extends FlxAtlasSprite implements IBPMSyncedScriptedClass
// I tried make this not interrupt an existing idle, // I tried make this not interrupt an existing idle,
// but isAnimationFinished() and isLoopComplete() both don't work! What the hell? // but isAnimationFinished() and isLoopComplete() both don't work! What the hell?
// danceEvery isn't necessary if that gets fixed. // danceEvery isn't necessary if that gets fixed.
//
if (getCurrentAnimation() == "idle") if (getCurrentAnimation() == "idle")
{ {
trace('Player beat hit'); trace('Player beat hit');

View file

@ -1,5 +1,6 @@
package funkin.ui.charSelect; package funkin.ui.charSelect;
import openfl.filters.BitmapFilter;
import flixel.FlxObject; import flixel.FlxObject;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.group.FlxGroup; import flixel.group.FlxGroup;
@ -31,6 +32,9 @@ import funkin.vis.dsp.SpectralAnalyzer;
import openfl.display.BlendMode; import openfl.display.BlendMode;
import funkin.save.Save; import funkin.save.Save;
import openfl.filters.ShaderFilter; import openfl.filters.ShaderFilter;
import funkin.util.FramesJSFLParser;
import funkin.util.FramesJSFLParser.FramesJSFLInfo;
import funkin.util.FramesJSFLParser.FramesJSFLFrame;
class CharSelectSubState extends MusicBeatSubState class CharSelectSubState extends MusicBeatSubState
{ {
@ -82,10 +86,16 @@ class CharSelectSubState extends MusicBeatSubState
var charSelectCam:FunkinCamera; var charSelectCam:FunkinCamera;
var selectedBizz:Array<BitmapFilter> = [
new DropShadowFilter(0, 0, 0xFFFFFF, 1, 2, 2, 21, 1, false, false, false),
new DropShadowFilter(5, 45, 0x000000, 1, 2, 2, 1, 1, false, false, false)
];
var bopInfo:FramesJSFLInfo;
public function new() public function new()
{ {
super(); super();
loadAvailableCharacters(); loadAvailableCharacters();
} }
@ -119,6 +129,8 @@ class CharSelectSubState extends MusicBeatSubState
{ {
super.create(); super.create();
bopInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/iconBopInfo/iconBopInfo.txt"));
var bg:FlxSprite = new FlxSprite(-153, -140); var bg:FlxSprite = new FlxSprite(-153, -140);
bg.loadGraphic(Paths.image('charSelect/charSelectBG')); bg.loadGraphic(Paths.image('charSelect/charSelectBG'));
bg.scrollFactor.set(0.1, 0.1); bg.scrollFactor.set(0.1, 0.1);
@ -281,10 +293,21 @@ class CharSelectSubState extends MusicBeatSubState
unlockSound = new FunkinSound(); unlockSound = new FunkinSound();
unlockSound.loadEmbedded(Paths.sound('CS_unlock')); unlockSound.loadEmbedded(Paths.sound('CS_unlock'));
unlockSound.pitch = 1; unlockSound.pitch = 1;
unlockSound.volume = 0.7;
unlockSound.volume = 0;
unlockSound.play(true);
FlxG.sound.defaultSoundGroup.add(unlockSound); FlxG.sound.defaultSoundGroup.add(unlockSound);
// 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,
});
initLocks(); initLocks();
for (index => member in grpIcons.members) for (index => member in grpIcons.members)
@ -384,16 +407,24 @@ class CharSelectSubState extends MusicBeatSubState
grpIcons.scrollFactor.set(); grpIcons.scrollFactor.set();
// playing it here to preload it. not doing this makes a super awkward pause at the end of the intro if (nonLocks.length > 0) unLock();
// TODO: probably make an intro thing for funkinSound itself that preloads the next audio? else
FunkinSound.playMusic('stayFunky', FunkinSound.playMusic('stayFunky',
{ {
startingVolume: 0, startingVolume: 1,
overrideExisting: true, overrideExisting: true,
restartTrack: true, restartTrack: true,
}); onLoad: function() {
@:privateAccess
unLock(); 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
}
});
} }
function unLock() function unLock()
@ -428,15 +459,37 @@ class CharSelectSubState extends MusicBeatSubState
lock.playAnimation("unlock"); lock.playAnimation("unlock");
unlockSound.volume = 0.7;
unlockSound.play(true); unlockSound.play(true);
lock.onAnimationComplete.addOnce(function(_) { lock.onAnimationComplete.addOnce(function(_) {
var char = availableChars.get(index);
camera.flash(0xFFFFFFFF, 0.1); camera.flash(0xFFFFFFFF, 0.1);
playerChill.playAnimation("unlock"); playerChill.playAnimation("unlock");
playerChill.visible = true; playerChill.visible = true;
var id = grpIcons.members.indexOf(lock);
nametag.switchChar(char);
gfChill.switchGF(char);
var icon = new PixelatedIcon(0, 0);
icon.setCharacter(char);
icon.setGraphicSize(128, 128);
icon.updateHitbox();
grpIcons.insert(id, icon);
grpIcons.remove(lock, true);
icon.ID = 0;
bopPlay = true;
updateIconPositions();
if (nonLocks.length == 0) if (nonLocks.length == 0)
{ {
playerChillOut.onAnimationComplete.addOnce((_) -> playerChillOut.switchChar(char));
@:bypassAccessor curChar = char;
Save.instance.addCharacterSeen(char);
FunkinSound.playMusic('stayFunky', FunkinSound.playMusic('stayFunky',
{ {
startingVolume: 1, startingVolume: 1,
@ -713,6 +766,48 @@ class CharSelectSubState extends MusicBeatSubState
cursorDarkBlue.y = MathUtil.coolLerp(cursorDarkBlue.y, cursorLocIntended.y, lerpAmnt * 0.2); cursorDarkBlue.y = MathUtil.coolLerp(cursorDarkBlue.y, cursorLocIntended.y, lerpAmnt * 0.2);
} }
var bopTimer:Float = 0;
var delay = 1 / 24;
var bopFr = 0;
var bopPlay:Bool = false;
var bopRefX:Float = 0;
var bopRefY:Float = 0;
function doBop(icon:PixelatedIcon, elapsed:Float):Void
{
if (bopFr >= bopInfo.frames.length)
{
bopRefX = 0;
bopRefY = 0;
bopPlay = false;
bopFr = 0;
return;
}
bopTimer += elapsed;
if (bopTimer >= delay)
{
bopTimer -= bopTimer;
var refFrame = bopInfo.frames[bopInfo.frames.length - 1];
var curFrame = bopInfo.frames[bopFr];
var xDiff:Float = curFrame.x - refFrame.x;
var yDiff:Float = curFrame.y - refFrame.y;
var scaleXDiff:Float = curFrame.scaleX - refFrame.scaleX;
var scaleYDiff:Float = curFrame.scaleY - refFrame.scaleY;
icon.scale.set(2.6, 2.6);
icon.scale.add(scaleXDiff, scaleYDiff);
bopFr++;
}
}
public override function dispatchEvent(event:ScriptEvent):Void public override function dispatchEvent(event:ScriptEvent):Void
{ {
// super.dispatchEvent(event) dispatches event to module scripts. // super.dispatchEvent(event) dispatches event to module scripts.
@ -725,11 +820,6 @@ class CharSelectSubState extends MusicBeatSubState
function spamOnStep():Void function spamOnStep():Void
{ {
if (FlxG.keys.justPressed.B)
{
cursorY = 3;
cursorX = 3;
}
if (spamUp || spamDown || spamLeft || spamRight) if (spamUp || spamDown || spamLeft || spamRight)
{ {
// selectSound.changePitchBySemitone(1); // selectSound.changePitchBySemitone(1);
@ -776,7 +866,7 @@ class CharSelectSubState extends MusicBeatSubState
case "idle": case "idle":
lock.playAnimation("selected"); lock.playAnimation("selected");
case "selected" | "clicked": case "selected" | "clicked":
if (controls.ACCEPT) lock.playAnimation((FlxG.keys.pressed.CONTROL) ? "unlock" : "clicked", true); if (controls.ACCEPT) lock.playAnimation("clicked", true);
} }
} }
else else
@ -789,8 +879,19 @@ class CharSelectSubState extends MusicBeatSubState
if (index == getCurrentSelected()) if (index == getCurrentSelected())
{ {
// memb.pixels = memb.withDropShadow.clone(); // memb.pixels = memb.withDropShadow.clone();
if (memb.scale.x != 2.6) memb.filters = [new DropShadowFilter()]; memb.filters = selectedBizz;
memb.scale.set(2.6, 2.6);
if (bopPlay)
{
if (bopRefX == 0)
{
bopRefX = memb.x;
bopRefY = memb.y;
}
doBop(memb, FlxG.elapsed);
}
else
memb.scale.set(2.6, 2.6);
if (controls.ACCEPT) memb.animation.play("confirm"); if (controls.ACCEPT) memb.animation.play("confirm");
if (memb.animation.curAnim.name == "confirm" && controls.BACK) if (memb.animation.curAnim.name == "confirm" && controls.BACK)
@ -805,7 +906,7 @@ class CharSelectSubState extends MusicBeatSubState
else else
{ {
// memb.pixels = memb.noDropShadow.clone(); // memb.pixels = memb.noDropShadow.clone();
if (memb.scale.x == 2) memb.filters = []; memb.filters = null;
memb.scale.set(2, 2); memb.scale.set(2, 2);
} }
} }

View file

@ -32,6 +32,7 @@ import openfl.media.Video;
import openfl.net.NetStream; import openfl.net.NetStream;
import funkin.api.newgrounds.NGio; import funkin.api.newgrounds.NGio;
import openfl.display.BlendMode; import openfl.display.BlendMode;
import funkin.save.Save;
#if desktop #if desktop
#end #end
@ -272,6 +273,8 @@ class TitleState extends MusicBeatState
} }
#end #end
if (Save.instance.charactersSeen.contains("pico")) Save.instance.charactersSeen.remove("pico");
Conductor.instance.update(); Conductor.instance.update();
/* if (FlxG.onMobile) /* if (FlxG.onMobile)

View file

@ -25,9 +25,22 @@ class FramesJSFLParser
var x:Float = Std.parseFloat(frameInfo[0]); var x:Float = Std.parseFloat(frameInfo[0]);
var y:Float = Std.parseFloat(frameInfo[1]); var y:Float = Std.parseFloat(frameInfo[1]);
var alpha:Float = Std.parseFloat(frameInfo[2]); var alpha:Float = (frameInfo[2] != "undefined") ? Std.parseFloat(frameInfo[2]) : 100;
var shit:FramesJSFLFrame = {x: x, y: y, alpha: alpha}; var scaleX:Float = 1;
var scaleY:Float = 1;
if (frameInfo[3] != null) scaleX = Std.parseFloat(frameInfo[4]);
if (frameInfo[4] != null) scaleX = Std.parseFloat(frameInfo[4]);
var shit:FramesJSFLFrame =
{
x: x,
y: y,
alpha: alpha,
scaleX: scaleX,
scaleY: scaleY
};
output.frames.push(shit); output.frames.push(shit);
} }
@ -45,4 +58,6 @@ typedef FramesJSFLFrame =
var x:Float; var x:Float;
var y:Float; var y:Float;
var alpha:Float; var alpha:Float;
var scaleX:Float;
var scaleY:Float;
} }

View file

@ -6,6 +6,9 @@ class AnsiTrace
// but adds nice cute ANSI things // but adds nice cute ANSI things
public static function trace(v:Dynamic, ?info:haxe.PosInfos) public static function trace(v:Dynamic, ?info:haxe.PosInfos)
{ {
#if TREMOVE
return;
#end
var str = formatOutput(v, info); var str = formatOutput(v, info);
#if js #if js
if (js.Syntax.typeof(untyped console) != "undefined" && (untyped console).log != null) (untyped console).log(str); if (js.Syntax.typeof(untyped console) != "undefined" && (untyped console).log != null) (untyped console).log(str);