diff --git a/source/Boyfriend.hx b/source/Boyfriend.hx new file mode 100644 index 0000000..73a6d2b --- /dev/null +++ b/source/Boyfriend.hx @@ -0,0 +1,51 @@ +package; + +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.graphics.frames.FlxAtlasFrames; + +class Boyfriend extends FlxSprite +{ + private var animOffsets:Map>; + + 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; + animation.addByPrefix('idle', 'BF idle dance', 24, false); + animation.addByPrefix('singUP', 'BF NOTE UP', 24, false); + animation.addByPrefix('singLEFT', 'BF NOTE LEFT', 24, false); + animation.addByPrefix('singRIGHT', 'BF NOTE RIGHT', 24, false); + animation.addByPrefix('singDOWN', 'BF NOTE DOWN', 24, false); + animation.addByPrefix('hey', 'BF HEY', 24, false); + animation.play('idle'); + + addOffset("singUP", -25, 35); + addOffset("singRIGHT", -40, -8); + addOffset("singLEFT", 0, 0); + addOffset("singDOWN", 0, -45); + addOffset("hey", 0, -0); + } + + override function update(elapsed:Float) + { + super.update(elapsed); + + var daOffset = animOffsets.get(animation.curAnim.name); + + if (animOffsets.exists(animation.curAnim.name)) + { + offset.set(daOffset[0], daOffset[1]); + } + else + centerOffsets(); + } + + public function addOffset(name:String, x:Float = 0, y:Float = 0) + { + animOffsets[name] = [x, y]; + } +} diff --git a/source/PlayState.hx b/source/PlayState.hx index bbfda0a..3d3000e 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 boyfriend:FlxSprite; + private var boyfriend:Boyfriend; private var notes:FlxTypedGroup; @@ -59,16 +59,7 @@ class PlayState extends FlxState dad.animation.play('idle'); add(dad); - boyfriend = new FlxSprite(770, 450); - var tex = FlxAtlasFrames.fromSparrow(AssetPaths.BOYFRIEND__png, AssetPaths.BOYFRIEND__xml); - boyfriend.frames = tex; - boyfriend.animation.addByPrefix('idle', 'BF idle dance', 24, false); - boyfriend.animation.addByPrefix('singUP', 'BF NOTE UP', 24, false); - boyfriend.animation.addByPrefix('singLEFT', 'BF NOTE LEFT', 24, false); - boyfriend.animation.addByPrefix('singRIGHT', 'BF NOTE RIGHT', 24, false); - boyfriend.animation.addByPrefix('singDOWN', 'BF NOTE DOWN', 24, false); - boyfriend.animation.addByPrefix('hey', 'BF HEY', 24, false); - boyfriend.animation.play('idle'); + boyfriend = new Boyfriend(770, 450); add(boyfriend); strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10); @@ -209,18 +200,22 @@ class PlayState extends FlxState babyArrow.x += Note.swagWidth * 2; babyArrow.animation.addByPrefix('static', 'arrowUP'); babyArrow.animation.addByPrefix('pressed', 'up press', 24, false); + babyArrow.animation.addByPrefix('confirm', 'up confirm', 24, false); case 2: babyArrow.x += Note.swagWidth * 3; babyArrow.animation.addByPrefix('static', 'arrowRIGHT'); babyArrow.animation.addByPrefix('pressed', 'right press', 24, false); + babyArrow.animation.addByPrefix('confirm', 'right confirm', 24, false); case 3: babyArrow.x += Note.swagWidth * 1; babyArrow.animation.addByPrefix('static', 'arrowDOWN'); babyArrow.animation.addByPrefix('pressed', 'down press', 24, false); + babyArrow.animation.addByPrefix('confirm', 'down confirm', 24, false); case 4: babyArrow.x += Note.swagWidth * 0; babyArrow.animation.addByPrefix('static', 'arrowLEFT'); babyArrow.animation.addByPrefix('pressed', 'left press', 24, false); + babyArrow.animation.addByPrefix('confirm', 'left confirm', 24, false); } babyArrow.animation.play('static'); @@ -379,6 +374,15 @@ class PlayState extends FlxState if (leftR) spr.animation.play('static'); } + + if (spr.animation.curAnim.name == 'confirm') + { + spr.centerOffsets(); + spr.offset.x -= 13; + spr.offset.y -= 13; + } + else + spr.centerOffsets(); }); if (up || right || down || left) @@ -441,6 +445,14 @@ class PlayState extends FlxState boyfriend.animation.play('singLEFT'); } + playerStrums.forEach(function(spr:FlxSprite) + { + if (Math.abs(note.noteData) == spr.ID) + { + spr.animation.play('confirm', true); + } + }); + sectionScores[1][curSection] += note.noteScore; note.wasGoodHit = true; vocals.volume = 1;