From 76ea17bf71f23805997a935fa7f31f35e4d5b237 Mon Sep 17 00:00:00 2001 From: TheRealJake_12 <84357907+TheRealJake12@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:31:13 -0600 Subject: [PATCH] fuck, the notes are broken removed some other project code :trollface: clean the scroll code a little more fix optimize bugs run formatter --- source/Character.hx | 208 ++++++++++++++++----------------- source/Note.hx | 24 ++-- source/PlayState.hx | 137 ++++++++-------------- source/shader/RuntimeShader.hx | 2 +- source/stages/Stage.hx | 2 +- 5 files changed, 159 insertions(+), 214 deletions(-) diff --git a/source/Character.hx b/source/Character.hx index 443f393e..6fe66949 100644 --- a/source/Character.hx +++ b/source/Character.hx @@ -105,72 +105,68 @@ class Character extends FlxSprite var data:CharacterData = cast jsonData; - if (!FlxG.save.data.optimize) - { - var tex:FlxFramesCollection; - - if (data.AtlasType == 'PackerAtlas') - tex = Paths.getPackerAtlas(data.asset, 'shared'); - else if (data.AtlasType == 'TextureAtlas') - tex = Paths.getTextureAtlas(data.asset, 'shared'); - else if (data.AtlasType == 'JsonAtlas') - tex = Paths.getJSONAtlas(data.asset, 'shared'); - else - tex = Paths.getSparrowAtlas(data.asset, 'shared'); + var tex:FlxFramesCollection; + + if (data.AtlasType == 'PackerAtlas') + tex = Paths.getPackerAtlas(data.asset, 'shared'); + else if (data.AtlasType == 'TextureAtlas') + tex = Paths.getTextureAtlas(data.asset, 'shared'); + else if (data.AtlasType == 'JsonAtlas') + tex = Paths.getJSONAtlas(data.asset, 'shared'); + else + tex = Paths.getSparrowAtlas(data.asset, 'shared'); - frames = tex; - if (frames != null) - for (anim in data.animations) - { - var frameRate = anim.frameRate == null ? 24 : anim.frameRate; - var looped = anim.looped == null ? false : anim.looped; - var flipX = anim.flipX == null ? false : anim.flipX; - var flipY = anim.flipY == null ? false : anim.flipY; + frames = tex; + if (frames != null) + for (anim in data.animations) + { + var frameRate = anim.frameRate == null ? 24 : anim.frameRate; + var looped = anim.looped == null ? false : anim.looped; + var flipX = anim.flipX == null ? false : anim.flipX; + var flipY = anim.flipY == null ? false : anim.flipY; - if (anim.frameIndices != null) - { - animation.addByIndices(anim.name, anim.prefix, anim.frameIndices, "", Std.int(frameRate * PlayState.songMultiplier), looped, flipX, - flipY); - } - else - { - animation.addByPrefix(anim.name, anim.prefix, Std.int(frameRate * PlayState.songMultiplier), looped, flipX, flipY); - } + if (anim.frameIndices != null) + { + animation.addByIndices(anim.name, anim.prefix, anim.frameIndices, "", Std.int(frameRate * PlayState.songMultiplier), looped, flipX, flipY); + } + else + { + animation.addByPrefix(anim.name, anim.prefix, Std.int(frameRate * PlayState.songMultiplier), looped, flipX, flipY); + } - animOffsets[anim.name] = anim.offsets == null ? [0, 0] : anim.offsets; - animInterrupt[anim.name] = anim.interrupt == null ? true : anim.interrupt; + animOffsets[anim.name] = anim.offsets == null ? [0, 0] : anim.offsets; + animInterrupt[anim.name] = anim.interrupt == null ? true : anim.interrupt; - if (data.isDancing && anim.isDanced != null) - animDanced[anim.name] = anim.isDanced; + if (data.isDancing && anim.isDanced != null) + animDanced[anim.name] = anim.isDanced; - if (anim.nextAnim != null) - animNext[anim.name] = anim.nextAnim; - } + if (anim.nextAnim != null) + animNext[anim.name] = anim.nextAnim; + } - this.replacesGF = data.replacesGF == null ? false : data.replacesGF; - this.hasTrail = data.hasTrail == null ? false : data.hasTrail; - this.isDancing = data.isDancing == null ? false : data.isDancing; - this.charPos = data.charPos == null ? [0, 0] : data.charPos; - this.camPos = data.camPos == null ? [0, 0] : data.camPos; - this.camFollow = data.camFollow == null ? [0, 0] : data.camFollow; - this.holdLength = data.holdLength == null ? 4 : data.holdLength; - this.healthIcon = data.healthicon == null ? curCharacter : data.healthicon; - this.iconAnimated = data.iconAnimated == null ? false : data.iconAnimated; + this.replacesGF = data.replacesGF == null ? false : data.replacesGF; + this.hasTrail = data.hasTrail == null ? false : data.hasTrail; + this.isDancing = data.isDancing == null ? false : data.isDancing; + this.charPos = data.charPos == null ? [0, 0] : data.charPos; + this.camPos = data.camPos == null ? [0, 0] : data.camPos; + this.camFollow = data.camFollow == null ? [0, 0] : data.camFollow; + this.holdLength = data.holdLength == null ? 4 : data.holdLength; + this.healthIcon = data.healthicon == null ? curCharacter : data.healthicon; + this.iconAnimated = data.iconAnimated == null ? false : data.iconAnimated; - this.rgbColorArray = data.rgbArray == null ? [255, 0, 0] : data.rgbArray; + this.rgbColorArray = data.rgbArray == null ? [255, 0, 0] : data.rgbArray; - flipX = data.flipX == null ? false : data.flipX; + flipX = data.flipX == null ? false : data.flipX; - if (data.scale != null) - { - setGraphicSize(Std.int(width * data.scale)); - updateHitbox(); - } + if (data.scale != null) + { + setGraphicSize(Std.int(width * data.scale)); + updateHitbox(); + } - antialiasing = data.antialiasing == null ? FlxG.save.data.antialiasing : data.antialiasing; + antialiasing = data.antialiasing == null ? FlxG.save.data.antialiasing : data.antialiasing; - playAnim(data.startingAnim); - } + playAnim(data.startingAnim); if (data.barType == 'rgb') barColor = FlxColor.fromRGB(data.rgbArray[0], data.rgbArray[1], data.rgbArray[2]); @@ -254,45 +250,40 @@ class Character extends FlxSprite { if (!debugMode) { - if (!FlxG.save.data.optimize) + if (curCharacter != 'pico-speaker') { - if (curCharacter != 'pico-speaker') + if (animation.curAnim != null) { - if (animation.curAnim != null) - { - var canInterrupt = animInterrupt.get(animation.curAnim.name); + var canInterrupt = animInterrupt.get(animation.curAnim.name); - if (canInterrupt) + if (canInterrupt) + { + if (isDancing) { - if (isDancing) + danced = !danced; + + if (altAnim && animation.getByName('danceRight-alt') != null && animation.getByName('danceLeft-alt') != null) { - danced = !danced; - - if (altAnim - && animation.getByName('danceRight-alt') != null - && animation.getByName('danceLeft-alt') != null) - { - if (danced) - playAnim('danceRight-alt'); - else - playAnim('danceLeft-alt'); - } + if (danced) + playAnim('danceRight-alt'); else - { - if (danced) - playAnim('danceRight'); - else - playAnim('danceLeft'); - } + playAnim('danceLeft-alt'); } else { - if (altAnim && animation.getByName('idle-alt') != null) - playAnim('idle-alt', forced); + if (danced) + playAnim('danceRight'); else - playAnim('idle', forced); + playAnim('danceLeft'); } } + else + { + if (altAnim && animation.getByName('idle-alt') != null) + playAnim('idle-alt', forced); + else + playAnim('idle', forced); + } } } } @@ -301,41 +292,38 @@ class Character extends FlxSprite public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void { - if (!FlxG.save.data.optimize) + if (AnimName.endsWith('alt') && animation.getByName(AnimName) == null) { - if (AnimName.endsWith('alt') && animation.getByName(AnimName) == null) - { - #if debug - FlxG.log.warn(['Such alt animation doesnt exist: ' + AnimName]); - #end - AnimName = AnimName.split('-')[0]; - } + #if debug + FlxG.log.warn(['Such alt animation doesnt exist: ' + AnimName]); + #end + AnimName = AnimName.split('-')[0]; + } + + animation.play(AnimName, Force, Reversed, Frame); - animation.play(AnimName, Force, Reversed, Frame); + var daOffset = animOffsets.get(AnimName); + if (animOffsets.exists(AnimName)) + { + offset.set(daOffset[0], daOffset[1]); + } + else + offset.set(0, 0); - var daOffset = animOffsets.get(AnimName); - if (animOffsets.exists(AnimName)) + if (curCharacter == 'gf') + { + if (AnimName == 'singLEFT') { - offset.set(daOffset[0], daOffset[1]); + danced = true; } - else - offset.set(0, 0); - - if (curCharacter == 'gf') + else if (AnimName == 'singRIGHT') { - if (AnimName == 'singLEFT') - { - danced = true; - } - else if (AnimName == 'singRIGHT') - { - danced = false; - } + danced = false; + } - if (AnimName == 'singUP' || AnimName == 'singDOWN') - { - danced = !danced; - } + if (AnimName == 'singUP' || AnimName == 'singDOWN') + { + danced = !danced; } } } diff --git a/source/Note.hx b/source/Note.hx index b0ec5c7b..526aa03d 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -428,18 +428,6 @@ class Note extends FlxSprite } if (strumTime - Conductor.songPosition < -Ratings.timingWindows[0] && !wasGoodHit) tooLate = true; - case 'fuck': - if (strumTime - Conductor.songPosition <= ((Ratings.timingWindows[0]) * 3.4) - && strumTime - Conductor.songPosition >= (-Ratings.timingWindows[0]) * 3.6) - { - canBeHit = true; - } - else - { - canBeHit = false; - } - if (strumTime - Conductor.songPosition < -Ratings.timingWindows[0] && !wasGoodHit) - tooLate = true; default: if (strumTime - Conductor.songPosition <= (((Ratings.timingWindows[0]) * lateHitMult)) && strumTime - Conductor.songPosition >= (((-Ratings.timingWindows[0]) * earlyHitMult))) @@ -454,7 +442,8 @@ class Note extends FlxSprite if (isSustainNote) { isSustainEnd = spotInLine == parent.children.length - 1; - alpha = modAlpha * FlxG.save.data.alpha; // This is the correct way + alpha = !sustainActive + && (parent.tooLate || parent.wasGoodHit) ? (modAlpha * FlxG.save.data.alpha) / 2 : modAlpha * FlxG.save.data.alpha; // This is the correct way } else if (tooLate && !wasGoodHit) { @@ -486,6 +475,15 @@ class Note extends FlxSprite _lastValidChecked = ''; } + @:noCompletion + override function set_y(value:Float):Float + { + if (isSustainNote) + if (PlayStateChangeables.useDownscroll) + value -= height - swagWidth; + return super.set_y(value); + } + @:noCompletion override function set_clipRect(rect:FlxRect):FlxRect { diff --git a/source/PlayState.hx b/source/PlayState.hx index 17990143..b748ca54 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -720,11 +720,11 @@ class PlayState extends MusicBeatState } // Load Characters. - if (!stageTesting || !FlxG.save.data.optimize) + if (!stageTesting) { gf = new Character(400, 130, gfCheck); - if (!FlxG.save.data.optimize && gf.frames == null) + if (gf.frames == null) { #if debug FlxG.log.warn(["Couldn't load gf: " + gfCheck + ". Loading default gf"]); @@ -734,7 +734,7 @@ class PlayState extends MusicBeatState boyfriend = new Boyfriend(770, 450, SONG.player1); - if (!FlxG.save.data.optimize && boyfriend.frames == null) + if (boyfriend.frames == null) { #if debug FlxG.log.warn(["Couldn't load boyfriend: " + SONG.player1 + ". Loading default boyfriend"]); @@ -744,7 +744,7 @@ class PlayState extends MusicBeatState dad = new Character(100, 100, SONG.player2); - if (!FlxG.save.data.optimize && dad.frames == null) + if (dad.frames == null) { #if debug FlxG.log.warn(["Couldn't load opponent: " + SONG.player2 + ". Loading default opponent"]); @@ -3799,12 +3799,11 @@ class PlayState extends MusicBeatState if (swagRect == null) swagRect = new FlxRect(0, 0, daNote.frameWidth, daNote.frameHeight); - if (strumScrollType) + if (daNote.isSustainNote && daNote.prevNote.wasGoodHit) { - if (daNote.isSustainNote) + if (strumScrollType) { - var bpmRatio = (SONG.bpm / 100); - daNote.y = (strumY + Math.sin(angleDir) * daNote.distance) - (daNote.height - Note.swagWidth); + // daNote.y = (strumY + Math.sin(angleDir) * daNote.distance) - (daNote.height - Note.swagWidth); if ((PlayStateChangeables.botPlay || !daNote.mustPress @@ -3821,13 +3820,7 @@ class PlayState extends MusicBeatState } } } - } - else - { - daNote.y = (strumY - - 0.45 * ((Conductor.songPosition - daNote.strumTime) / songMultiplier) * (FlxMath.roundDecimal(leSpeed, 2))) - + daNote.noteYOff; - if (daNote.isSustainNote) + else { if ((PlayStateChangeables.botPlay || !daNote.mustPress @@ -4053,12 +4046,12 @@ class PlayState extends MusicBeatState else shownHealth = health; - var mult:Float = FlxMath.lerp(1, iconP1.scale.x, CoolUtil.boundTo(1 - (elapsed * 9 * songMultiplier), 0, 1)); + var mult:Float = FlxMath.lerp(1, iconP1.scale.x, FlxMath.bound(1 - (elapsed * 9 * songMultiplier), 0, 1)); if (!FlxG.save.data.motion) iconP1.scale.set(mult, mult); iconP1.updateHitbox(); - var mult:Float = FlxMath.lerp(1, iconP2.scale.x, CoolUtil.boundTo(1 - (elapsed * 9 * songMultiplier), 0, 1)); + var mult:Float = FlxMath.lerp(1, iconP2.scale.x, FlxMath.bound(1 - (elapsed * 9 * songMultiplier), 0, 1)); if (!FlxG.save.data.motion) iconP2.scale.set(mult, mult); iconP2.updateHitbox(); @@ -4718,7 +4711,8 @@ class PlayState extends MusicBeatState case 'marv': currentTimingShown.color = FlxColor.CYAN; } - currentTimingShown.borderStyle = OUTLINE; + currentTimingShown.font = Paths.font('vcr.ttf'); + currentTimingShown.borderStyle = OUTLINE_FAST; currentTimingShown.borderSize = 1; currentTimingShown.borderColor = FlxColor.BLACK; currentTimingShown.text = msTiming + "ms"; @@ -4769,9 +4763,6 @@ class PlayState extends MusicBeatState comboSpr.x += 5.5; comboSpr.y += 29.5; } - /*currentTimingShown.y = rating.y + 100; - currentTimingShown.acceleration.y = 600; - currentTimingShown.velocity.y -= 150; */ comboSpr.velocity.x += FlxG.random.int(1, 10); @@ -5315,48 +5306,44 @@ class PlayState extends MusicBeatState health -= 0.8; } } + if (!daNote.wasGoodHit) + { + if (daNote.isParent) + for (i in daNote.children) + i.sustainActive = true; - if (daNote.isParent) - for (i in daNote.children) - i.sustainActive = true; - - if (!PlayStateChangeables.opponentMode) - dad.holdTimer = 0; - else - boyfriend.holdTimer = 0; + if (!PlayStateChangeables.opponentMode) + dad.holdTimer = 0; + else + boyfriend.holdTimer = 0; - if (PlayStateChangeables.healthDrain) - { - if (!daNote.isSustainNote) + if (PlayStateChangeables.healthDrain) { - updateScoreText(); - if (!PlayStateChangeables.opponentMode) + if (!daNote.isSustainNote) { - health -= 0.08 * PlayStateChangeables.healthLoss; - if (health <= 0.01) + updateScoreText(); + if (!PlayStateChangeables.opponentMode) { - health = 0.01; + health -= 0.08 * PlayStateChangeables.healthLoss; + if (health <= 0.01) + { + health = 0.01; + } + } + else + { + health += 0.08 * PlayStateChangeables.healthLoss; + if (health >= 2) + health = 2; } } - else - { - health += 0.08 * PlayStateChangeables.healthLoss; - if (health >= 2) - health = 2; - } - } - else - { } - } - // Accessing the animation name directly to play it - if (!daNote.isParent && daNote.parent != null) - { + if (!daNote.isSustainEnd) { var singData:Int = Std.int(Math.abs(daNote.noteData)); - if (!FlxG.save.data.optimize) + if (!FlxG.save.data.optimize && daNote.canPlayAnims) { if (PlayStateChangeables.opponentMode) boyfriend.playAnim('sing' + dataSuffix[singData] + altAnim, true); @@ -5380,18 +5367,12 @@ class PlayState extends MusicBeatState vocalsEnemy.volume = 1; } } + + daNote.wasGoodHit = true; } - else - { - var singData:Int = Std.int(Math.abs(daNote.noteData)); - if (!FlxG.save.data.optimize && daNote.canPlayAnims) - { - if (PlayStateChangeables.opponentMode) - boyfriend.playAnim('sing' + dataSuffix[singData] + altAnim, true); - else - dad.playAnim('sing' + dataSuffix[singData] + altAnim, true); - } + if (!daNote.isSustainNote) + { if (FlxG.save.data.cpuStrums) { if (FlxG.save.data.cpuSplash && daNote.canNoteSplash && !FlxG.save.data.middleScroll) @@ -5399,26 +5380,6 @@ class PlayState extends MusicBeatState spawnNoteSplashOnNoteDad(daNote); } } - - if (FlxG.save.data.cpuStrums) - { - cpuStrums.forEach(function(spr:StaticArrow) - { - pressArrow(spr, spr.ID, daNote); - }); - } - - if (!PlayStateChangeables.opponentMode) - dad.holdTimer = 0; - else - boyfriend.holdTimer = 0; - if (SONG.needsVoices) - { - if (!SONG.splitVoiceTracks) - vocals.volume = 1; - else - vocalsEnemy.volume = 1; - } } #if FEATURE_LUAMODCHART @@ -5495,9 +5456,9 @@ class PlayState extends MusicBeatState daHitSound.play(); } } - combo += 1; popUpScore(note); + /* Enable Sustains to be hit. // This is to prevent hitting sustains if you hold a strum before the note is coming without hitting the note parent. (I really hope I made me understand lol.) */ @@ -5555,15 +5516,13 @@ class PlayState extends MusicBeatState updateAccuracy(); updateScoreText(); } - else - { - note.wasGoodHit = true; - } - + if (SONG.splitVoiceTracks != true) vocals.volume = 1; else vocalsPlayer.volume = 1; + + note.wasGoodHit = true; } } @@ -5670,8 +5629,8 @@ class PlayState extends MusicBeatState { if (curStep % 4 == 0) { - iconP1.scale.set(1.15, 1.15); - iconP2.scale.set(1.15, 1.15); + iconP1.scale.set(1.2, 1.2); + iconP2.scale.set(1.2, 1.2); iconP1.updateHitbox(); iconP2.updateHitbox(); diff --git a/source/shader/RuntimeShader.hx b/source/shader/RuntimeShader.hx index 6bf67374..0ae294fd 100644 --- a/source/shader/RuntimeShader.hx +++ b/source/shader/RuntimeShader.hx @@ -11,4 +11,4 @@ class RuntimeShader extends FlxRuntimeShader super(frag, vertex); this.name = name; } -} \ No newline at end of file +} diff --git a/source/stages/Stage.hx b/source/stages/Stage.hx index 790669cf..357daad0 100644 --- a/source/stages/Stage.hx +++ b/source/stages/Stage.hx @@ -735,7 +735,7 @@ class Stage extends MusicBeatState bg.animation.play('idle', true); } - if (FlxG.save.data.distractions && FlxG.save.data.background) + if (FlxG.save.data.distractions && FlxG.save.data.background && !FlxG.save.data.optimize) { switch (curStage) {