mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-02-17 04:11:23 -05:00
more freeplay stuff in progress
This commit is contained in:
parent
2dd270f83e
commit
b54c459539
2 changed files with 98 additions and 19 deletions
|
@ -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<Alphabet>;
|
||||
private var grpCapsules:FlxTypedGroup<SongMenuItem>;
|
||||
private var curPlaying:Bool = false;
|
||||
|
||||
private var iconArray:Array<HealthIcon> = [];
|
||||
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<Alphabet>();
|
||||
add(grpSongs);
|
||||
|
||||
grpCapsules = new FlxTypedGroup<SongMenuItem>();
|
||||
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()
|
||||
|
|
71
source/freeplayStuff/SongMenuItem.hx
Normal file
71
source/freeplayStuff/SongMenuItem.hx
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue