From d7aba46853592f71788ac6305f39c45f11a0d0fc Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 8 Mar 2021 18:38:58 -0500 Subject: [PATCH] tankmen foreground in progress --- source/BGSprite.hx | 30 +++++++++++++++++++++++++++--- source/PauseSubState.hx | 29 ++++++++++++++++++++++++----- source/PlayState.hx | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 85 insertions(+), 11 deletions(-) diff --git a/source/BGSprite.hx b/source/BGSprite.hx index 6af1fadd6..a1013b015 100644 --- a/source/BGSprite.hx +++ b/source/BGSprite.hx @@ -7,13 +7,37 @@ class BGSprite extends FlxSprite /** Cool lil utility thing just so that it can easy do antialiasing and scrollfactor bullshit */ - public function new(image:String, x:Float = 0, y:Float = 0, parX:Float = 1, parY:Float = 1) + public var idleAnim:String; + + public function new(image:String, x:Float = 0, y:Float = 0, parX:Float = 1, parY:Float = 1, ?daAnimations:Array) { super(x, y); - loadGraphic(Paths.image(image)); + if (daAnimations != null) + { + frames = Paths.getSparrowAtlas(image); + for (anims in daAnimations) + { + animation.addByPrefix(anims, anims, 24, false); + animation.play(anims); + + if (idleAnim == null) + idleAnim = anims; + } + } + else + { + loadGraphic(Paths.image(image)); + active = false; + } + scrollFactor.set(parX, parY); antialiasing = true; - active = false; + } + + public function dance():Void + { + if (idleAnim != null) + animation.play(idleAnim); } } diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index c340d8ed2..f0215ee10 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -17,7 +17,13 @@ class PauseSubState extends MusicBeatSubstate { var grpMenuShit:FlxTypedGroup; - var pauseOG:Array = ['Resume', 'Restart Song', 'Change Difficulty', 'Exit to menu']; + var pauseOG:Array = [ + 'Resume', + 'Restart Song', + 'Change Difficulty', + 'Toggle Practice Mode', + 'Exit to menu' + ]; var difficultyChoices:Array = ['EASY', 'NORMAL', 'HARD', 'BACK']; var menuItems:Array = []; @@ -25,6 +31,8 @@ class PauseSubState extends MusicBeatSubstate var pauseMusic:FlxSound; + var practiceText:FlxText; + public function new(x:Float, y:Float) { super(); @@ -63,6 +71,14 @@ class PauseSubState extends MusicBeatSubstate deathCounter.updateHitbox(); add(deathCounter); + practiceText = new FlxText(20, 15 + 64 + 32, 0, "PRACTICE MODE", 32); + practiceText.scrollFactor.set(); + practiceText.setFormat(Paths.font('vcr.ttf'), 32); + practiceText.updateHitbox(); + practiceText.x = FlxG.width - (practiceText.width + 20); + practiceText.visible = PlayState.practiceMode; + add(practiceText); + levelDifficulty.alpha = 0; levelInfo.alpha = 0; deathCounter.alpha = 0; @@ -86,11 +102,10 @@ class PauseSubState extends MusicBeatSubstate private function regenMenu():Void { - grpMenuShit.forEachAlive(function(thing:Alphabet) + while (grpMenuShit.members.length > 0) { - grpMenuShit.remove(thing); - thing.destroy(); - }); + grpMenuShit.remove(grpMenuShit.members[0], true); + } for (i in 0...menuItems.length) { @@ -140,6 +155,10 @@ class PauseSubState extends MusicBeatSubstate FlxG.resetState(); + case 'Toggle Practice Mode': + PlayState.practiceMode = !PlayState.practiceMode; + practiceText.visible = PlayState.practiceMode; + case 'Change Difficulty': menuItems = difficultyChoices; regenMenu(); diff --git a/source/PlayState.hx b/source/PlayState.hx index 9f17da0c0..c864df782 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -50,6 +50,7 @@ class PlayState extends MusicBeatState public static var storyPlaylist:Array = []; public static var storyDifficulty:Int = 1; public static var deathCounter:Int = 0; + public static var practiceMode:Bool = false; var halloweenLevel:Bool = false; @@ -99,6 +100,8 @@ class PlayState extends MusicBeatState var phillyTrain:FlxSprite; var trainSound:FlxSound; + var foregroundSprites:FlxTypedGroup; + var limo:FlxSprite; var grpLimoDancers:FlxTypedGroup; var fastCar:FlxSprite; @@ -147,6 +150,8 @@ class PlayState extends MusicBeatState Conductor.mapBPMChanges(SONG); Conductor.changeBPM(SONG.bpm); + foregroundSprites = new FlxTypedGroup(); + switch (SONG.song.toLowerCase()) { case 'tutorial': @@ -470,7 +475,7 @@ class PlayState extends MusicBeatState */ case 'guns' | 'stress' | 'ugh': - // defaultCamZoom = 0.9; + // defaultCamZoom = 0.95; curStage = 'tank'; var bg:BGSprite = new BGSprite('tankSky', 0, -200, 0, 0); @@ -491,9 +496,28 @@ class PlayState extends MusicBeatState var tankWatchtower:BGSprite = new BGSprite('tankWatchtower', 300, 50, 0.5, 0.5); add(tankWatchtower); - var tankGround:BGSprite = new BGSprite('tankGround', -400, -20); + var tankGround:BGSprite = new BGSprite('tankGround', -200, -20); add(tankGround); + var fgTank0:BGSprite = new BGSprite('tank0', -290, 400, 1.7, 1.5, ['fg']); + foregroundSprites.add(fgTank0); + + var fgTank1:BGSprite = new BGSprite('tank1', -100, 680, 2, 0.2, ['fg']); + foregroundSprites.add(fgTank1); + + // just called 'foreground' just cuz small inconsistency no bbiggei + var fgTank2:BGSprite = new BGSprite('tank2', 450, 840, 1.5, 1.5, ['foreground']); + foregroundSprites.add(fgTank2); + + var fgTank4:BGSprite = new BGSprite('tank4', 1000, 880, 1.5, 1.5, ['fg']); + foregroundSprites.add(fgTank4); + + var fgTank5:BGSprite = new BGSprite('tank5', 1400, 600, 1.5, 1.5, ['fg']); + foregroundSprites.add(fgTank5); + + var fgTank3:BGSprite = new BGSprite('tank3', 1300, 1130, 3.5, 2.5, ['fg']); + foregroundSprites.add(fgTank3); + default: defaultCamZoom = 0.9; curStage = 'stage'; @@ -630,6 +654,8 @@ class PlayState extends MusicBeatState add(dad); add(boyfriend); + add(foregroundSprites); + var doof:DialogueBox = new DialogueBox(false, dialogue); // doof.x += 70; // doof.y = FlxG.height * 0.5; @@ -1470,7 +1496,7 @@ class PlayState extends MusicBeatState trace("User is cheating!"); } - if (health <= 0) + if (health <= 0 && !practiceMode) { boyfriend.stunned = true; @@ -2310,6 +2336,11 @@ class PlayState extends MusicBeatState } } + foregroundSprites.forEach(function(spr:BGSprite) + { + spr.dance(); + }); + switch (curStage) { case 'school':