diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index e68773949..e8ec9effe 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -14,7 +14,9 @@ import flixel.math.FlxPoint; import flixel.text.FlxText; import flixel.tweens.FlxTween; import flixel.util.FlxColor; +import flixel.util.FlxTimer; import freeplayStuff.DJBoyfriend; +import freeplayStuff.SongMenuItem; import lime.app.Future; import lime.utils.Assets; @@ -45,10 +47,10 @@ class FreeplayState extends MusicBeatState ]; private var grpSongs:FlxTypedGroup; + private var grpCapsules:FlxTypedGroup; private var curPlaying:Bool = false; private var iconArray:Array = []; - var bg:FlxSprite; var scoreBG:FlxSprite; override function create() @@ -106,32 +108,44 @@ class FreeplayState extends MusicBeatState // LOAD CHARACTERS - bg = new FlxSprite().loadGraphic(Paths.image('menuDesat')); - bg.setGraphicSize(Std.int(FlxG.width)); - bg.updateHitbox(); trace(FlxG.width); trace(FlxG.camera.zoom); trace(FlxG.camera.initialZoom); trace(FlxCamera.defaultZoom); trace(FlxG.initialZoom); - add(bg); grpSongs = new FlxTypedGroup(); add(grpSongs); + grpCapsules = new FlxTypedGroup(); + add(grpCapsules); + for (i in 0...songs.length) { + var funnyMenu:SongMenuItem = new SongMenuItem(FlxG.width, (i * 150) + 160, songs[i].songName); + funnyMenu.targetPos.x = funnyMenu.x; + funnyMenu.ID = i; + + new FlxTimer().start((0.06 * i) + 0.8, function(lerpTmr) + { + funnyMenu.doLerp = true; + }); + + grpCapsules.add(funnyMenu); + var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i].songName, true, false); + songText.x += 100; songText.isMenuItem = true; songText.targetY = i; - grpSongs.add(songText); + + // grpSongs.add(songText); var icon:HealthIcon = new HealthIcon(songs[i].songCharacter); icon.sprTracker = songText; // using a FlxGroup is too much fuss! iconArray.push(icon); - add(icon); + // add(icon); // songText.x += 40; // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! @@ -233,7 +247,6 @@ class FreeplayState extends MusicBeatState } lerpScore = CoolUtil.coolLerp(lerpScore, intendedScore, 0.4); - bg.color = FlxColor.interpolate(bg.color, coolColors[songs[curSelected].week % coolColors.length], CoolUtil.camLerpShit(0.045)); scoreText.text = "PERSONAL BEST:" + Math.round(lerpScore); @@ -461,20 +474,15 @@ class FreeplayState extends MusicBeatState iconArray[curSelected].alpha = 1; - for (item in grpSongs.members) + for (index => capsule in grpCapsules.members) { - item.targetY = bullShit - curSelected; - bullShit++; + capsule.selected = false; - 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)); - } + capsule.targetPos.y = ((index - curSelected) * 150) + 160; + capsule.targetPos.x = 270 + (60 * (Math.sin(index - curSelected))); } + + grpCapsules.members[curSelected].selected = true; } function positionHighscore() diff --git a/source/freeplayStuff/SongMenuItem.hx b/source/freeplayStuff/SongMenuItem.hx new file mode 100644 index 000000000..253740c65 --- /dev/null +++ b/source/freeplayStuff/SongMenuItem.hx @@ -0,0 +1,71 @@ +package freeplayStuff; + +import flixel.FlxSprite; +import flixel.graphics.frames.FlxAtlasFrames; +import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; +import flixel.group.FlxSpriteGroup; +import flixel.math.FlxMath; +import flixel.math.FlxPoint; +import flixel.text.FlxText; + +class SongMenuItem extends FlxSpriteGroup +{ + var capsule:FlxSprite; + + public var selected(default, set):Bool = false; + + public var songTitle:String = "Test"; + + var songText:FlxText; + + public var targetPos:FlxPoint = new FlxPoint(); + public var doLerp:Bool = false; + + public function new(x:Float, y:Float, song:String) + { + super(x, y); + + this.songTitle = song; + + capsule = new FlxSprite(); + capsule.frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule'); + capsule.animation.addByPrefix('selected', 'mp3 capsule w backing0', 24); + capsule.animation.addByPrefix('unselected', 'mp3 capsule w backing NOT SELECTED', 24); + // capsule.animation + add(capsule); + + songText = new FlxText(120, 40, 0, songTitle, 40); + songText.font = "5by7"; + songText.color = 0xFF43C1EA; + add(songText); + + selected = selected; // just to kickstart the set_selected + } + + override function update(elapsed:Float) + { + if (doLerp) + { + x = CoolUtil.coolLerp(x, targetPos.x, 0.3); + y = CoolUtil.coolLerp(y, targetPos.y, 0.4); + } + + if (FlxG.keys.justPressed.ALT) + selected = false; + if (FlxG.keys.justPressed.CONTROL) + selected = true; + + super.update(elapsed); + } + + function set_selected(value:Bool):Bool + { + trace(value); + + // cute one liners, lol! + songText.alpha = value ? 1 : 0.6; + capsule.offset.x = value ? 0 : -5; + capsule.animation.play(value ? "selected" : "unselected"); + return value; + } +}