fixed the dad bullshit

This commit is contained in:
Cameron Taylor
2020-10-04 15:27:49 -07:00
parent dbbd0c2851
commit de17188ae4
7 changed files with 166 additions and 175 deletions

View File

@@ -1,6 +1,7 @@
package;
import flixel.FlxG;
import flixel.FlxObject;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.addons.display.FlxGridOverlay;
@@ -13,42 +14,75 @@ import flixel.text.FlxText;
class Charting extends FlxState
{
var bf:Boyfriend;
var dad:Dad;
var char:Character;
var textAnim:FlxText;
var dumbTexts:FlxTypedGroup<FlxText>;
var animList:Array<String> = [];
var curAnim:Int = 0;
var isDad:Bool = false;
var camFollow:FlxObject;
public function new(isDad:Bool = false)
{
super();
this.isDad = isDad;
}
override function create()
{
FlxG.sound.music.stop();
var gridBG:FlxSprite = FlxGridOverlay.create(4, 4);
var gridBG:FlxSprite = FlxGridOverlay.create(10, 10);
gridBG.scrollFactor.set(0.5, 0.5);
add(gridBG);
bf = new Boyfriend(0, 0);
bf.screenCenter();
bf.debugMode = true;
add(bf);
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;
}
dumbTexts = new FlxTypedGroup<FlxText>();
add(dumbTexts);
textAnim = new FlxText();
textAnim = new FlxText(300, 16);
textAnim.size = 26;
textAnim.scrollFactor.set();
add(textAnim);
genBoyOffsets();
camFollow = new FlxObject(0, 0, 2, 2);
camFollow.screenCenter();
add(camFollow);
FlxG.camera.follow(camFollow);
super.create();
}
function genBoyOffsets(pushList:Bool = true):Void
{
var daLoop:Int = 0;
for (anim => offsets in bf.animOffsets)
for (anim => offsets in char.animOffsets)
{
var text:FlxText = new FlxText(10, 20 + (18 * daLoop), 0, anim + ": " + offsets, 15);
text.scrollFactor.set();
dumbTexts.add(text);
if (pushList)
@@ -69,8 +103,33 @@ class Charting extends FlxState
override function update(elapsed:Float)
{
textAnim.setPosition(bf.x, bf.y - 60);
textAnim.text = bf.animation.curAnim.name;
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();
}
if (FlxG.keys.justPressed.W)
{
@@ -90,7 +149,10 @@ class Charting extends FlxState
if (FlxG.keys.justPressed.S || FlxG.keys.justPressed.W || FlxG.keys.justPressed.SPACE)
{
bf.animation.play(animList[curAnim]);
char.playAnim(animList[curAnim]);
updateTexts();
genBoyOffsets(false);
}
var upP = FlxG.keys.anyJustPressed([UP]);
@@ -98,20 +160,26 @@ class Charting extends FlxState
var downP = FlxG.keys.anyJustPressed([DOWN]);
var leftP = FlxG.keys.anyJustPressed([LEFT]);
var holdShift = FlxG.keys.pressed.SHIFT;
var multiplier = 1;
if (holdShift)
multiplier = 10;
if (upP || rightP || downP || leftP)
{
updateTexts();
if (upP)
bf.animOffsets.get(animList[curAnim])[1] += 1;
char.animOffsets.get(animList[curAnim])[1] += 1 * multiplier;
if (downP)
bf.animOffsets.get(animList[curAnim])[1] -= 1;
char.animOffsets.get(animList[curAnim])[1] -= 1 * multiplier;
if (leftP)
bf.animOffsets.get(animList[curAnim])[0] += 1;
char.animOffsets.get(animList[curAnim])[0] += 1 * multiplier;
if (rightP)
bf.animOffsets.get(animList[curAnim])[0] -= 1;
char.animOffsets.get(animList[curAnim])[0] -= 1 * multiplier;
updateTexts();
genBoyOffsets(false);
char.playAnim(animList[curAnim]);
}
super.update(elapsed);