mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-04 22:04:29 +00:00
106 lines
2.2 KiB
Haxe
106 lines
2.2 KiB
Haxe
package;
|
|
|
|
import flixel.FlxG;
|
|
import flixel.FlxSprite;
|
|
import flixel.addons.display.FlxGridOverlay;
|
|
import flixel.text.FlxText;
|
|
|
|
#if switch
|
|
import openfl.events.GameInputEvent;
|
|
import openfl.ui.GameInput;
|
|
import openfl.ui.GameInputDevice;
|
|
import openfl.ui.GameInputControl;
|
|
#end
|
|
|
|
class FreeplayState extends MusicBeatState
|
|
{
|
|
var songs:Array<String> = ["Bopeebo", "Dadbattle", "Fresh", "Tutorial", "Spookeez", "South", "Monster"];
|
|
|
|
var selector:FlxText;
|
|
var curSelected:Int = 0;
|
|
|
|
override function create()
|
|
{
|
|
// LOAD MUSIC
|
|
|
|
// LOAD CHARACTERS
|
|
|
|
var bg:FlxSprite = FlxGridOverlay.create(20, 20);
|
|
add(bg);
|
|
|
|
for (i in 0...songs.length)
|
|
{
|
|
var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i], true, false);
|
|
add(songText);
|
|
songText.x += 40;
|
|
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
|
|
// songText.screenCenter(X);
|
|
}
|
|
|
|
FlxG.sound.playMusic('assets/music/title' + TitleState.soundExt, 0);
|
|
FlxG.sound.music.fadeIn(2, 0, 0.8);
|
|
selector = new FlxText();
|
|
|
|
selector.size = 40;
|
|
selector.text = ">";
|
|
add(selector);
|
|
|
|
var swag:Alphabet = new Alphabet(1, 0, "swag");
|
|
|
|
super.create();
|
|
}
|
|
|
|
override function update(elapsed:Float)
|
|
{
|
|
super.update(elapsed);
|
|
var upP = controls.UP_P;
|
|
var downP = controls.DOWN_P;
|
|
var accepted = controls.ACCEPT;
|
|
|
|
if (upP)
|
|
{
|
|
curSelected -= 1;
|
|
}
|
|
if (downP)
|
|
{
|
|
curSelected += 1;
|
|
}
|
|
|
|
#if switch
|
|
if (gamepad.anyJustPressed(["UP", "DPAD_UP", "LEFT_STICK_DIGITAL_UP"]))
|
|
{
|
|
curSelected -= 1;
|
|
}
|
|
if (gamepad.anyJustPressed(["DOWN", "DPAD_DOWN", "LEFT_STICK_DIGITAL_DOWN"]))
|
|
{
|
|
curSelected += 1;
|
|
}
|
|
#end
|
|
|
|
if (curSelected < 0)
|
|
curSelected = songs.length - 1;
|
|
if (curSelected >= songs.length)
|
|
curSelected = 0;
|
|
|
|
selector.y = (70 * curSelected) + 30;
|
|
|
|
if (accepted)
|
|
{
|
|
PlayState.SONG = Song.loadFromJson(songs[curSelected].toLowerCase());
|
|
PlayState.isStoryMode = false;
|
|
FlxG.switchState(new PlayState());
|
|
FlxG.sound.music.stop();
|
|
}
|
|
|
|
#if switch
|
|
if (gamepad.anyJustPressed(["B"])) //"B" is swapped with "A" on Switch
|
|
{
|
|
PlayState.SONG = Song.loadFromJson(songs[curSelected].toLowerCase());
|
|
PlayState.isStoryMode = false;
|
|
FlxG.switchState(new PlayState());
|
|
FlxG.sound.music.stop();
|
|
}
|
|
#end
|
|
}
|
|
}
|