From 5b2412cf6fe0dd515c30cbd4fc6a4eac26e4734d Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 30 Mar 2021 13:58:05 -0700 Subject: [PATCH] tankman/picospeaker better syncs --- source/Character.hx | 2 ++ source/PlayState.hx | 45 +++++++++++++++++++++++++------------------- source/TankmenBG.hx | 12 ++++++------ source/TitleState.hx | 1 - 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/source/Character.hx b/source/Character.hx index 042778b78..3e203e61d 100644 --- a/source/Character.hx +++ b/source/Character.hx @@ -501,6 +501,8 @@ class Character extends FlxSprite } } + TankmenBG.animationNotes = animationNotes; + trace(animationNotes); } diff --git a/source/PlayState.hx b/source/PlayState.hx index 505d9267e..5c7e5584f 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -492,7 +492,7 @@ class PlayState extends MusicBeatState */ case 'guns' | 'stress' | 'ugh': - // defaultCamZoom = 0.95; + defaultCamZoom = 0.90; curStage = 'tank'; var bg:BGSprite = new BGSprite('tankSky', 0, -200, 0, 0); @@ -591,6 +591,13 @@ class PlayState extends MusicBeatState case 'pico-speaker': gf.x -= 50; gf.y -= 200; + + for (i in 0...TankmenBG.animationNotes.length) + { + var tankman:TankmenBG = new TankmenBG(500, 200 + FlxG.random.int(0, 150), TankmenBG.animationNotes[i][1] < 2); + tankman.strumTime = TankmenBG.animationNotes[i][0]; + tankmanRun.add(tankman); + } } dad = new Character(100, 100, SONG.player2); @@ -2017,8 +2024,18 @@ class PlayState extends MusicBeatState { // control arrays, order L D R U var holdArray:Array = [controls.NOTE_LEFT, controls.NOTE_DOWN, controls.NOTE_UP, controls.NOTE_RIGHT]; - var pressArray:Array = [controls.NOTE_LEFT_P, controls.NOTE_DOWN_P, controls.NOTE_UP_P, controls.NOTE_RIGHT_P]; - var releaseArray:Array = [controls.NOTE_LEFT_R, controls.NOTE_DOWN_R, controls.NOTE_UP_R, controls.NOTE_RIGHT_R]; + var pressArray:Array = [ + controls.NOTE_LEFT_P, + controls.NOTE_DOWN_P, + controls.NOTE_UP_P, + controls.NOTE_RIGHT_P + ]; + var releaseArray:Array = [ + controls.NOTE_LEFT_R, + controls.NOTE_DOWN_R, + controls.NOTE_UP_R, + controls.NOTE_RIGHT_R + ]; // HOLDS, check for sustain notes if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic) @@ -2048,13 +2065,13 @@ class PlayState extends MusicBeatState for (coolNote in possibleNotes) { if (coolNote.noteData == daNote.noteData && Math.abs(daNote.strumTime - coolNote.strumTime) < 10) - { // if it's the same note twice at < 10ms distance, just delete it + { // if it's the same note twice at < 10ms distance, just delete it // EXCEPT u cant delete it in this loop cuz it fucks with the collection lol dumbNotes.push(daNote); break; } else if (coolNote.noteData == daNote.noteData && daNote.strumTime < coolNote.strumTime) - { // if daNote is earlier than existing note (coolNote), replace + { // if daNote is earlier than existing note (coolNote), replace possibleNotes.remove(coolNote); possibleNotes.push(daNote); break; @@ -2071,7 +2088,7 @@ class PlayState extends MusicBeatState for (note in dumbNotes) { - FlxG.log.add("killing dumb ass note at "+note.strumTime); + FlxG.log.add("killing dumb ass note at " + note.strumTime); note.kill(); notes.remove(note, true); note.destroy(); @@ -2084,7 +2101,7 @@ class PlayState extends MusicBeatState else if (possibleNotes.length > 0) { for (shit in 0...pressArray.length) - { // if a direction is hit that shouldn't be + { // if a direction is hit that shouldn't be if (pressArray[shit] && !directionList.contains(shit)) badNoteHit(); } @@ -2321,7 +2338,8 @@ class PlayState extends MusicBeatState override function stepHit() { super.stepHit(); - if (Math.abs(FlxG.sound.music.time - Conductor.songPosition) > 20 || (SONG.needsVoices && Math.abs(vocals.time - Conductor.songPosition) > 20)) + if (Math.abs(FlxG.sound.music.time - Conductor.songPosition) > 20 + || (SONG.needsVoices && Math.abs(vocals.time - Conductor.songPosition) > 20)) { resyncVocals(); } @@ -2455,17 +2473,6 @@ class PlayState extends MusicBeatState } } - switch (curSong.toLowerCase()) - { - case 'stress': - if (FlxG.random.bool()) - { - var tank:TankmenBG = new TankmenBG(500, 200); - tank.strumTime = Conductor.songPosition + (Conductor.crochet * 4); - tankmanRun.add(tank); - } - } - if (isHalloween && FlxG.random.bool(10) && curBeat > lightningStrikeBeat + lightningOffset) { lightningStrikeShit(); diff --git a/source/TankmenBG.hx b/source/TankmenBG.hx index bdd56e8a3..6a703151a 100644 --- a/source/TankmenBG.hx +++ b/source/TankmenBG.hx @@ -6,13 +6,15 @@ import haxe.display.Display.Package; class TankmenBG extends FlxSprite { + public static var animationNotes:Array = []; + public var strumTime:Float = 0; public var goingRight:Bool = false; public var tankSpeed:Float = 0.7; public var endingOffset:Float; - public function new(x:Float, y:Float) + public function new(x:Float, y:Float, isGoingRight:Bool) { super(x, y); @@ -25,12 +27,10 @@ class TankmenBG extends FlxSprite animation.play('run'); - y += FlxG.random.int(-40, 100); + goingRight = isGoingRight; + endingOffset = FlxG.random.float(50, 200); - goingRight = FlxG.random.bool(); - endingOffset = FlxG.random.float(0, 120); - - tankSpeed = FlxG.random.float(0.65, 0.8); + tankSpeed = FlxG.random.float(0.6, 1); if (goingRight) flipX = true; diff --git a/source/TitleState.hx b/source/TitleState.hx index b658244a1..81f8244df 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -1,6 +1,5 @@ package; -import animate.AnimationAtlas; import flixel.FlxG; import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond;