diff --git a/assets/images/DADDY_DEAREST.png b/assets/images/DADDY_DEAREST.png index 8f66d4606..7d93cbb58 100644 Binary files a/assets/images/DADDY_DEAREST.png and b/assets/images/DADDY_DEAREST.png differ diff --git a/assets/images/DADDY_DEAREST.xml b/assets/images/DADDY_DEAREST.xml index 86aef3b8f..2cb7619c4 100644 --- a/assets/images/DADDY_DEAREST.xml +++ b/assets/images/DADDY_DEAREST.xml @@ -2,128 +2,21 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/source/Boyfriend.hx b/source/Boyfriend.hx index a201bd290..0dc9c72c6 100644 --- a/source/Boyfriend.hx +++ b/source/Boyfriend.hx @@ -4,16 +4,11 @@ import flixel.FlxG; import flixel.FlxSprite; import flixel.graphics.frames.FlxAtlasFrames; -class Boyfriend extends FlxSprite +class Boyfriend extends Character { - public var animOffsets:Map>; - - public var debugMode:Bool = false; - public function new(x:Float, y:Float) { super(x, y); - animOffsets = new Map>(); var tex = FlxAtlasFrames.fromSparrow(AssetPaths.BOYFRIEND__png, AssetPaths.BOYFRIEND__xml); frames = tex; @@ -37,20 +32,4 @@ class Boyfriend extends FlxSprite { super.update(elapsed); } - - public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void - { - animation.play(AnimName, Force, Reversed, Frame); - - var daOffset = animOffsets.get(animation.curAnim.name); - if (animOffsets.exists(animation.curAnim.name)) - { - offset.set(daOffset[0], daOffset[1]); - } - } - - public function addOffset(name:String, x:Float = 0, y:Float = 0) - { - animOffsets[name] = [x, y]; - } } diff --git a/source/Character.hx b/source/Character.hx new file mode 100644 index 000000000..8caf4f37a --- /dev/null +++ b/source/Character.hx @@ -0,0 +1,31 @@ +package; + +import flixel.FlxSprite; + +class Character extends FlxSprite +{ + public var animOffsets:Map>; + public var debugMode:Bool = false; + + public function new(x:Float, y:Float) + { + animOffsets = new Map>(); + super(x, y); + } + + public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void + { + animation.play(AnimName, Force, Reversed, Frame); + + var daOffset = animOffsets.get(animation.curAnim.name); + if (animOffsets.exists(animation.curAnim.name)) + { + offset.set(daOffset[0], daOffset[1]); + } + } + + public function addOffset(name:String, x:Float = 0, y:Float = 0) + { + animOffsets[name] = [x, y]; + } +} diff --git a/source/Charting.hx b/source/Charting.hx index 2468dbba8..9aad403e1 100644 --- a/source/Charting.hx +++ b/source/Charting.hx @@ -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; var animList:Array = []; 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(); 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); diff --git a/source/Dad.hx b/source/Dad.hx new file mode 100644 index 000000000..25641838b --- /dev/null +++ b/source/Dad.hx @@ -0,0 +1,25 @@ +package; + +import flixel.graphics.frames.FlxAtlasFrames; + +class Dad extends Character +{ + public function new(x:Float, y:Float) + { + super(x, y); + var dadTex = FlxAtlasFrames.fromSparrow(AssetPaths.DADDY_DEAREST__png, AssetPaths.DADDY_DEAREST__xml); + frames = dadTex; + animation.addByPrefix('idle', 'Dad idle dance', 24); + animation.addByPrefix('singUP', 'Dad Sing Note UP', 24); + animation.addByPrefix('singRIGHT', 'Dad Sing Note UP', 24); + animation.addByPrefix('singDOWN', 'Dad Sing Note DOWN', 24); + animation.addByPrefix('singLEFT', 'Dad Sing Note RIGHT', 24); + playAnim('idle'); + + addOffset('idle'); + addOffset("singUP", -6, 50); + addOffset("singRIGHT", -6, 50); + addOffset("singLEFT", -10, 10); + addOffset("singDOWN", 0, -30); + } +} diff --git a/source/PlayState.hx b/source/PlayState.hx index 4ff812852..d190e8e19 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -33,7 +33,7 @@ class PlayState extends FlxState private var canHitText:FlxText; - private var dad:FlxSprite; + private var dad:Dad; private var boyfriend:Boyfriend; private var notes:FlxTypedGroup; @@ -53,15 +53,8 @@ class PlayState extends FlxState bg.scrollFactor.set(0.5, 0.5); add(bg); - dad = new FlxSprite(100, 100).loadGraphic(AssetPaths.DADDY_DEAREST__png); - var dadTex = FlxAtlasFrames.fromSparrow(AssetPaths.DADDY_DEAREST__png, AssetPaths.DADDY_DEAREST__xml); - dad.frames = dadTex; - dad.animation.addByPrefix('idle', 'Dad idle dance', 24); - dad.animation.addByPrefix('singUP', 'Dad Sing note UP', 24); - dad.animation.addByPrefix('singRIGHT', 'Dad Sing note UP', 24); - dad.animation.addByPrefix('singDOWN', 'Dad Sing Note DOWN', 24); - dad.animation.addByPrefix('singLEFT', 'dad sing note right', 24); - dad.animation.play('idle'); + dad = new Dad(100, 100); + add(dad); boyfriend = new Boyfriend(770, 450); @@ -240,6 +233,8 @@ class PlayState extends FlxState if (FlxG.keys.justPressed.NINE) FlxG.switchState(new Charting()); + if (FlxG.keys.justPressed.EIGHT) + FlxG.switchState(new Charting(true)); Conductor.songPosition = FlxG.sound.music.time; var playerTurn:Int = totalBeats % 8; @@ -297,13 +292,13 @@ class PlayState extends FlxState switch (Math.abs(daNote.noteData)) { case 1: - dad.animation.play('singUP'); + dad.playAnim('singUP'); case 2: - dad.animation.play('singRIGHT'); + dad.playAnim('singRIGHT'); case 3: - dad.animation.play('singDOWN'); + dad.playAnim('singDOWN'); case 4: - dad.animation.play('singLEFT'); + dad.playAnim('singLEFT'); } daNote.kill();