2020-10-21 14:05:27 -04:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxG;
|
|
|
|
import flixel.FlxSprite;
|
2020-10-25 16:51:06 -04:00
|
|
|
import flixel.addons.display.FlxGridOverlay;
|
2020-11-01 14:16:22 -05:00
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
2020-10-21 14:05:27 -04:00
|
|
|
import flixel.text.FlxText;
|
|
|
|
|
|
|
|
class FreeplayState extends MusicBeatState
|
|
|
|
{
|
2020-11-01 14:16:22 -05:00
|
|
|
var songs:Array<String> = ["Bopeebo", "Dadbattle", "Fresh", "Tutorial"];
|
2020-10-21 14:05:27 -04:00
|
|
|
|
|
|
|
var selector:FlxText;
|
|
|
|
var curSelected:Int = 0;
|
|
|
|
|
2020-11-01 14:16:22 -05:00
|
|
|
private var grpSongs:FlxTypedGroup<Alphabet>;
|
|
|
|
|
2020-10-21 14:05:27 -04:00
|
|
|
override function create()
|
|
|
|
{
|
2020-11-01 14:16:22 -05:00
|
|
|
if (!FlxG.sound.music.playing)
|
|
|
|
FlxG.sound.playMusic('assets/music/freakyMenu' + TitleState.soundExt);
|
|
|
|
|
|
|
|
if (StoryMenuState.weekUnlocked[1])
|
|
|
|
{
|
|
|
|
songs.push('Spookeez');
|
|
|
|
songs.push('South');
|
|
|
|
}
|
|
|
|
|
2020-10-21 14:05:27 -04:00
|
|
|
// LOAD MUSIC
|
|
|
|
|
|
|
|
// LOAD CHARACTERS
|
|
|
|
|
2020-11-01 14:16:22 -05:00
|
|
|
var bg:FlxSprite = new FlxSprite().loadGraphic(AssetPaths.menuBGBlue__png);
|
2020-10-25 16:51:06 -04:00
|
|
|
add(bg);
|
|
|
|
|
2020-11-01 14:16:22 -05:00
|
|
|
grpSongs = new FlxTypedGroup<Alphabet>();
|
|
|
|
add(grpSongs);
|
|
|
|
|
2020-10-21 14:05:27 -04:00
|
|
|
for (i in 0...songs.length)
|
|
|
|
{
|
2020-10-30 19:47:19 -04:00
|
|
|
var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i], true, false);
|
2020-11-01 14:16:22 -05:00
|
|
|
songText.isMenuItem = true;
|
|
|
|
songText.targetY = i;
|
|
|
|
grpSongs.add(songText);
|
|
|
|
// songText.x += 40;
|
2020-10-30 19:47:19 -04:00
|
|
|
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
|
|
|
|
// songText.screenCenter(X);
|
2020-10-21 14:05:27 -04:00
|
|
|
}
|
|
|
|
|
2020-11-01 14:16:22 -05:00
|
|
|
changeSelection();
|
|
|
|
|
|
|
|
// FlxG.sound.playMusic('assets/music/title' + TitleState.soundExt, 0);
|
|
|
|
// FlxG.sound.music.fadeIn(2, 0, 0.8);
|
2020-10-21 14:05:27 -04:00
|
|
|
selector = new FlxText();
|
2020-10-30 19:47:19 -04:00
|
|
|
|
2020-10-25 16:51:06 -04:00
|
|
|
selector.size = 40;
|
2020-10-21 14:05:27 -04:00
|
|
|
selector.text = ">";
|
2020-11-01 14:16:22 -05:00
|
|
|
// add(selector);
|
2020-10-21 14:05:27 -04:00
|
|
|
|
2020-10-25 16:51:06 -04:00
|
|
|
var swag:Alphabet = new Alphabet(1, 0, "swag");
|
|
|
|
|
2020-10-21 14:05:27 -04:00
|
|
|
super.create();
|
|
|
|
}
|
|
|
|
|
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
2020-10-30 19:47:19 -04:00
|
|
|
super.update(elapsed);
|
|
|
|
var upP = controls.UP_P;
|
|
|
|
var downP = controls.DOWN_P;
|
|
|
|
var accepted = controls.ACCEPT;
|
|
|
|
|
|
|
|
if (upP)
|
2020-10-21 14:05:27 -04:00
|
|
|
{
|
2020-11-01 14:16:22 -05:00
|
|
|
changeSelection(-1);
|
2020-10-21 14:05:27 -04:00
|
|
|
}
|
2020-10-30 19:47:19 -04:00
|
|
|
if (downP)
|
2020-10-21 14:05:27 -04:00
|
|
|
{
|
2020-11-01 14:16:22 -05:00
|
|
|
changeSelection(1);
|
2020-10-21 14:05:27 -04:00
|
|
|
}
|
|
|
|
|
2020-11-01 14:16:22 -05:00
|
|
|
if (controls.BACK)
|
|
|
|
{
|
|
|
|
FlxG.switchState(new MainMenuState());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (accepted)
|
|
|
|
{
|
|
|
|
PlayState.SONG = Song.loadFromJson(songs[curSelected].toLowerCase(), songs[curSelected].toLowerCase());
|
|
|
|
PlayState.isStoryMode = false;
|
|
|
|
FlxG.switchState(new PlayState());
|
|
|
|
FlxG.sound.music.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeSelection(change:Int = 0)
|
|
|
|
{
|
|
|
|
curSelected += change;
|
2020-10-26 19:06:42 -04:00
|
|
|
|
2020-10-21 14:05:27 -04:00
|
|
|
if (curSelected < 0)
|
|
|
|
curSelected = songs.length - 1;
|
|
|
|
if (curSelected >= songs.length)
|
|
|
|
curSelected = 0;
|
|
|
|
|
2020-11-01 14:16:22 -05:00
|
|
|
// selector.y = (70 * curSelected) + 30;
|
2020-10-21 14:05:27 -04:00
|
|
|
|
2020-11-01 14:16:22 -05:00
|
|
|
var bullShit:Int = 0;
|
|
|
|
|
|
|
|
for (item in grpSongs.members)
|
2020-10-21 19:33:43 -04:00
|
|
|
{
|
2020-11-01 14:16:22 -05:00
|
|
|
item.targetY = bullShit - curSelected;
|
|
|
|
bullShit++;
|
2020-10-21 19:33:43 -04:00
|
|
|
|
2020-11-01 14:16:22 -05:00
|
|
|
item.alpha = 0.6;
|
|
|
|
// item.setGraphicSize(Std.int(item.width * 0.8));
|
|
|
|
|
|
|
|
if (item.targetY == 0)
|
2020-10-26 19:06:42 -04:00
|
|
|
{
|
2020-11-01 14:16:22 -05:00
|
|
|
item.alpha = 1;
|
|
|
|
// item.setGraphicSize(Std.int(item.width));
|
2020-10-26 19:06:42 -04:00
|
|
|
}
|
2020-11-01 14:16:22 -05:00
|
|
|
}
|
2020-10-21 14:05:27 -04:00
|
|
|
}
|
|
|
|
}
|