From f419163ccc880344728666886262eac3733682c1 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 17 Nov 2020 17:50:09 -0800 Subject: [PATCH] pause menu in progress --- source/PauseSubState.hx | 84 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 10 deletions(-) diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index dbf232b6d..2fdbefbf7 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -4,11 +4,17 @@ import Controls.Control; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxSubState; +import flixel.group.FlxGroup.FlxTypedGroup; import flixel.input.keyboard.FlxKey; import flixel.util.FlxColor; -class PauseSubState extends FlxSubState +class PauseSubState extends MusicBeatSubstate { + var grpMenuShit:FlxTypedGroup; + + var menuItems:Array = ['Resume', 'Restart Song', 'Exit to menu']; + var curSelected:Int = 0; + public function new(x:Float, y:Float) { super(); @@ -17,25 +23,83 @@ class PauseSubState extends FlxSubState bg.scrollFactor.set(); add(bg); - var bf:Boyfriend = new Boyfriend(x, y); - bf.scrollFactor.set(); - // add(bf); + grpMenuShit = new FlxTypedGroup(); + add(grpMenuShit); - bf.playAnim('firstDeath'); + for (i in 0...menuItems.length) + { + var songText:Alphabet = new Alphabet(0, (70 * i) + 30, menuItems[i], true, false); + songText.isMenuItem = true; + songText.targetY = i; + grpMenuShit.add(songText); + } - bg.cameras = [FlxG.cameras.list[1]]; + changeSelection(); + + cameras = [FlxG.cameras.list[1]]; } override function update(elapsed:Float) { super.update(elapsed); - if (FlxG.keys.justPressed.J) + var upP = controls.UP_P; + var downP = controls.DOWN_P; + var accepted = controls.ACCEPT; + + if (upP) { - PlayerSettings.player1.controls.replaceBinding(Control.LEFT, Keys, FlxKey.J, null); + changeSelection(-1); + } + if (downP) + { + changeSelection(1); } - if (FlxG.keys.justPressed.ENTER) - close(); + if (accepted) + { + var daSelected:String = menuItems[curSelected]; + + switch (daSelected) + { + case "Resume": + close(); + case "Exit to menu": + FlxG.switchState(new MainMenuState()); + } + } + + if (FlxG.keys.justPressed.J) + { + // for reference later! + // PlayerSettings.player1.controls.replaceBinding(Control.LEFT, Keys, FlxKey.J, null); + } + } + + function changeSelection(change:Int = 0):Void + { + curSelected += change; + + if (curSelected < 0) + curSelected = menuItems.length - 1; + if (curSelected >= menuItems.length) + curSelected = 0; + + var bullShit:Int = 0; + + for (item in grpMenuShit.members) + { + item.targetY = bullShit - curSelected; + bullShit++; + + item.alpha = 0.6; + // item.setGraphicSize(Std.int(item.width * 0.8)); + + if (item.targetY == 0) + { + item.alpha = 1; + // item.setGraphicSize(Std.int(item.width)); + } + } } }