1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-27 15:37:49 +00:00
Funkin/source/AnimationDebug.hx

190 lines
3.6 KiB
Haxe
Raw Normal View History

2020-10-04 06:42:58 +00:00
package;
import flixel.FlxG;
2020-10-04 22:27:49 +00:00
import flixel.FlxObject;
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-05 00:53:49 +00:00
import flixel.util.FlxColor;
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;
2020-10-04 22:27:49 +00:00
var dad:Dad;
var char:Character;
2020-10-04 21:44:52 +00:00
var textAnim:FlxText;
var dumbTexts:FlxTypedGroup<FlxText>;
var animList:Array<String> = [];
var curAnim:Int = 0;
2020-10-04 22:27:49 +00:00
var isDad:Bool = false;
var camFollow:FlxObject;
public function new(isDad:Bool = false)
{
super();
this.isDad = isDad;
}
2020-10-04 21:44:52 +00:00
2020-10-04 06:42:58 +00:00
override function create()
{
FlxG.sound.music.stop();
2020-10-04 22:27:49 +00:00
var gridBG:FlxSprite = FlxGridOverlay.create(10, 10);
gridBG.scrollFactor.set(0.5, 0.5);
2020-10-04 21:44:52 +00:00
add(gridBG);
2020-10-04 22:27:49 +00:00
if (isDad)
{
dad = new Dad(0, 0);
dad.screenCenter();
dad.debugMode = true;
add(dad);
char = dad;
}
else
{
bf = new Boyfriend(0, 0);
bf.screenCenter();
bf.debugMode = true;
add(bf);
char = bf;
}
2020-10-04 21:44:52 +00:00
dumbTexts = new FlxTypedGroup<FlxText>();
add(dumbTexts);
2020-10-04 22:27:49 +00:00
textAnim = new FlxText(300, 16);
2020-10-04 21:44:52 +00:00
textAnim.size = 26;
2020-10-04 22:27:49 +00:00
textAnim.scrollFactor.set();
2020-10-04 21:44:52 +00:00
add(textAnim);
genBoyOffsets();
2020-10-04 22:27:49 +00:00
camFollow = new FlxObject(0, 0, 2, 2);
camFollow.screenCenter();
add(camFollow);
FlxG.camera.follow(camFollow);
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;
2020-10-04 22:27:49 +00:00
for (anim => offsets in char.animOffsets)
2020-10-04 21:44:52 +00:00
{
var text:FlxText = new FlxText(10, 20 + (18 * daLoop), 0, anim + ": " + offsets, 15);
2020-10-04 22:27:49 +00:00
text.scrollFactor.set();
2020-10-05 00:53:49 +00:00
text.color = FlxColor.BLUE;
2020-10-04 21:44:52 +00:00
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)
{
2020-10-04 22:27:49 +00:00
textAnim.text = char.animation.curAnim.name;
if (FlxG.keys.justPressed.E)
FlxG.camera.zoom += 0.25;
if (FlxG.keys.justPressed.Q)
FlxG.camera.zoom -= 0.25;
if (FlxG.keys.pressed.I || FlxG.keys.pressed.J || FlxG.keys.pressed.K || FlxG.keys.pressed.L)
{
if (FlxG.keys.pressed.I)
camFollow.velocity.y = -90;
else if (FlxG.keys.pressed.K)
camFollow.velocity.y = 90;
else
camFollow.velocity.y = 0;
if (FlxG.keys.pressed.J)
camFollow.velocity.x = -90;
else if (FlxG.keys.pressed.L)
camFollow.velocity.x = 90;
else
camFollow.velocity.x = 0;
}
else
{
camFollow.velocity.set();
}
2020-10-04 21:44:52 +00:00
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)
{
2020-10-04 22:27:49 +00:00
char.playAnim(animList[curAnim]);
updateTexts();
genBoyOffsets(false);
2020-10-04 21:44:52 +00:00
}
var upP = FlxG.keys.anyJustPressed([UP]);
var rightP = FlxG.keys.anyJustPressed([RIGHT]);
var downP = FlxG.keys.anyJustPressed([DOWN]);
var leftP = FlxG.keys.anyJustPressed([LEFT]);
2020-10-04 22:27:49 +00:00
var holdShift = FlxG.keys.pressed.SHIFT;
var multiplier = 1;
if (holdShift)
multiplier = 10;
2020-10-04 21:44:52 +00:00
if (upP || rightP || downP || leftP)
{
updateTexts();
if (upP)
2020-10-04 22:27:49 +00:00
char.animOffsets.get(animList[curAnim])[1] += 1 * multiplier;
2020-10-04 21:44:52 +00:00
if (downP)
2020-10-04 22:27:49 +00:00
char.animOffsets.get(animList[curAnim])[1] -= 1 * multiplier;
2020-10-04 21:44:52 +00:00
if (leftP)
2020-10-04 22:27:49 +00:00
char.animOffsets.get(animList[curAnim])[0] += 1 * multiplier;
2020-10-04 21:44:52 +00:00
if (rightP)
2020-10-04 22:27:49 +00:00
char.animOffsets.get(animList[curAnim])[0] -= 1 * multiplier;
2020-10-04 21:44:52 +00:00
updateTexts();
genBoyOffsets(false);
2020-10-04 22:27:49 +00:00
char.playAnim(animList[curAnim]);
2020-10-04 21:44:52 +00:00
}
super.update(elapsed);
}
2020-10-04 06:42:58 +00:00
}