1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-09 16:24:42 +00:00
Funkin/source/Charting.hx

120 lines
2.2 KiB
Haxe
Raw Normal View History

2020-10-04 06:42:58 +00:00
package;
import flixel.FlxG;
2020-10-04 21:44:52 +00:00
import flixel.FlxSprite;
2020-10-04 06:42:58 +00:00
import flixel.FlxState;
2020-10-04 21:44:52 +00:00
import flixel.addons.display.FlxGridOverlay;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.text.FlxText;
2020-10-04 06:42:58 +00:00
2020-10-04 21:44:52 +00:00
/**
*DEBUG MODE
*/
2020-10-04 06:42:58 +00:00
class Charting extends FlxState
{
2020-10-04 21:44:52 +00:00
var bf:Boyfriend;
var textAnim:FlxText;
var dumbTexts:FlxTypedGroup<FlxText>;
var animList:Array<String> = [];
var curAnim:Int = 0;
2020-10-04 06:42:58 +00:00
override function create()
{
FlxG.sound.music.stop();
2020-10-04 21:44:52 +00:00
var gridBG:FlxSprite = FlxGridOverlay.create(4, 4);
add(gridBG);
bf = new Boyfriend(0, 0);
bf.screenCenter();
bf.debugMode = true;
add(bf);
dumbTexts = new FlxTypedGroup<FlxText>();
add(dumbTexts);
textAnim = new FlxText();
textAnim.size = 26;
add(textAnim);
genBoyOffsets();
2020-10-04 06:42:58 +00:00
super.create();
}
2020-10-04 21:44:52 +00:00
function genBoyOffsets(pushList:Bool = true):Void
{
var daLoop:Int = 0;
for (anim => offsets in bf.animOffsets)
{
var text:FlxText = new FlxText(10, 20 + (18 * daLoop), 0, anim + ": " + offsets, 15);
dumbTexts.add(text);
if (pushList)
animList.push(anim);
daLoop++;
}
}
function updateTexts():Void
{
dumbTexts.forEach(function(text:FlxText)
{
text.kill();
dumbTexts.remove(text, true);
});
}
override function update(elapsed:Float)
{
textAnim.setPosition(bf.x, bf.y - 60);
textAnim.text = bf.animation.curAnim.name;
if (FlxG.keys.justPressed.W)
{
curAnim -= 1;
}
if (FlxG.keys.justPressed.S)
{
curAnim += 1;
}
if (curAnim < 0)
curAnim = animList.length - 1;
if (curAnim >= animList.length)
curAnim = 0;
if (FlxG.keys.justPressed.S || FlxG.keys.justPressed.W || FlxG.keys.justPressed.SPACE)
{
bf.animation.play(animList[curAnim]);
}
var upP = FlxG.keys.anyJustPressed([UP]);
var rightP = FlxG.keys.anyJustPressed([RIGHT]);
var downP = FlxG.keys.anyJustPressed([DOWN]);
var leftP = FlxG.keys.anyJustPressed([LEFT]);
if (upP || rightP || downP || leftP)
{
updateTexts();
if (upP)
bf.animOffsets.get(animList[curAnim])[1] += 1;
if (downP)
bf.animOffsets.get(animList[curAnim])[1] -= 1;
if (leftP)
bf.animOffsets.get(animList[curAnim])[0] += 1;
if (rightP)
bf.animOffsets.get(animList[curAnim])[0] -= 1;
updateTexts();
genBoyOffsets(false);
}
super.update(elapsed);
}
2020-10-04 06:42:58 +00:00
}