From 98a77811beef53d01166483be216a091b2dd384c Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 14 Jul 2021 20:32:09 -0400 Subject: [PATCH] new combo stuf --- source/ComboCounter.hx | 119 +++++++++++++++++++++++++++++++++++++++++ source/PlayState.hx | 9 ++++ source/TitleState.hx | 4 +- 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 source/ComboCounter.hx diff --git a/source/ComboCounter.hx b/source/ComboCounter.hx new file mode 100644 index 000000000..e2be5539a --- /dev/null +++ b/source/ComboCounter.hx @@ -0,0 +1,119 @@ +package; + +import flixel.FlxSprite; +import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; + +class ComboCounter extends FlxTypedSpriteGroup +{ + var effectStuff:FlxSprite; + + var wasComboSetup:Bool = false; + var daCombo:Int = 0; + + var grpNumbers:FlxTypedGroup; + + public function new(x:Float, y:Float, daCombo:Int = 0) + { + super(x, y); + + this.daCombo = daCombo; + + effectStuff = new FlxSprite(0, 0); + effectStuff.frames = Paths.getSparrowAtlas('noteCombo'); + effectStuff.animation.addByPrefix('funny', 'NOTE COMBO animation', 24, false); + effectStuff.animation.play('funny'); + effectStuff.antialiasing = true; + effectStuff.animation.finishCallback = function(nameThing) + { + kill(); + }; + add(effectStuff); + + grpNumbers = new FlxTypedGroup(); + // add(grpNumbers); + } + + override function update(elapsed:Float) + { + if (effectStuff.animation.curAnim.curFrame == 2 && !wasComboSetup) + { + setupCombo(daCombo); + } + + if (effectStuff.animation.curAnim.curFrame == 18) + { + grpNumbers.forEach(function(spr:ComboNumber) + { + spr.animation.reset(); + }); + } + + if (effectStuff.animation.curAnim.curFrame == 20) + { + grpNumbers.forEach(function(spr:ComboNumber) + { + spr.kill(); + }); + } + + super.update(elapsed); + } + + function setupCombo(daCombo:Int) + { + FlxG.sound.play(Paths.sound('comboSound')); + + wasComboSetup = true; + var loopNum:Int = 0; + + while (daCombo > 0) + { + var comboNumber:ComboNumber = new ComboNumber(420 - (130 * loopNum), 44 * loopNum, daCombo % 10); + grpNumbers.add(comboNumber); + add(comboNumber); + + loopNum += 1; + + daCombo = Math.floor(daCombo / 10); + } + + // var comboNumber:ComboNumber = new ComboNumber(420, 0, 0); + + // add to both, in the group just for ez organize/accessing + // grpNumbers.add(comboNumber); + // add(comboNumber); + + // var comboNumber2:ComboNumber = new ComboNumber(420 - 134, 44, 0); + // grpNumbers.add(comboNumber2); + // add(comboNumber2); + } +} + +class ComboNumber extends FlxSprite +{ + public function new(x:Float, y:Float, digit:Int) + { + super(x - 20, y); + + var stringNum:String = Std.string(digit); + frames = Paths.getSparrowAtlas('noteComboNumbers'); + animation.addByPrefix(stringNum, stringNum, 24, false); + animation.play(stringNum); + antialiasing = true; + updateHitbox(); + } + + var shiftedX:Bool = false; + + override function update(elapsed:Float) + { + if (animation.curAnim.curFrame == 2 && !shiftedX) + { + shiftedX = true; + x += 20; + } + + super.update(elapsed); + } +} diff --git a/source/PlayState.hx b/source/PlayState.hx index e2d2ff426..8bb078d0f 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -3008,6 +3008,15 @@ class PlayState extends MusicBeatState iconP1.updateHitbox(); iconP2.updateHitbox(); + if (curBeat % 8 == 7 + && SONG.notes[Math.floor(curStep / 16)].mustHitSection + && combo > 5 + && !SONG.notes[Math.floor(curStep / 16) + 1].mustHitSection) + { + var animShit:ComboCounter = new ComboCounter(-100, 300, combo); + add(animShit); + } + if (curBeat % gfSpeed == 0) gf.dance(); diff --git a/source/TitleState.hx b/source/TitleState.hx index 201e57edf..e6a0aa516 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -301,9 +301,11 @@ class TitleState extends MusicBeatState // FlxTween.tween(logoBl, {y: logoBl.y + 50}, 0.6, {ease: FlxEase.quadInOut, type: PINGPONG}); // FlxTween.tween(logo, {y: logoBl.y + 50}, 0.6, {ease: FlxEase.quadInOut, type: PINGPONG, startDelay: 0.1}); - + var animShit:ComboCounter = new ComboCounter(200, 200, 1423); + add(animShit); credGroup = new FlxGroup(); add(credGroup); + textGroup = new FlxGroup(); blackScreen = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);