1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-26 15:07:14 +00:00

random capsule in progres

This commit is contained in:
Cameron Taylor 2023-08-06 16:24:34 -04:00 committed by EliteMasterEric
parent 65422393cf
commit eb87d40d58
3 changed files with 128 additions and 89 deletions

View file

@ -466,7 +466,7 @@ class FreeplayState extends MusicBeatSubState
public function generateSongList(?filterStuff:SongFilter, force:Bool = false)
{
curSelected = 0;
curSelected = 1;
grpCapsules.clear();
@ -492,9 +492,38 @@ class FreeplayState extends MusicBeatSubState
}
}
// if (regexp != null)
// tempSongs = songs.filter(item -> regexp.match(item.songName));
// tempSongs.sort(function(a, b):Int
// {
// var tempA = a.songName.toUpperCase();
// var tempB = b.songName.toUpperCase();
// if (tempA < tempB)
// return -1;
// else if (tempA > tempB)
// return 1;
// else
// return 0;
// });
var randomCapsule:SongMenuItem = new SongMenuItem(FlxG.width, 0, "Random");
randomCapsule.onConfirm = function() {
trace("RANDOM SELECTED");
};
randomCapsule.y = randomCapsule.intendedY(0) + 10;
randomCapsule.targetPos.x = randomCapsule.x;
randomCapsule.alpha = 0.5;
randomCapsule.songText.visible = false;
randomCapsule.favIcon.visible = false;
randomCapsule.initJumpIn(0, force);
grpCapsules.add(randomCapsule);
for (i in 0...tempSongs.length)
{
var funnyMenu:SongMenuItem = new SongMenuItem(FlxG.width, 0, tempSongs[i].songName);
funnyMenu.onConfirm = capsuleOnConfirmDefault;
funnyMenu.y = funnyMenu.intendedY(i + 1) + 10;
funnyMenu.targetPos.x = funnyMenu.x;
funnyMenu.ID = i;
@ -503,29 +532,7 @@ class FreeplayState extends MusicBeatSubState
funnyMenu.favIcon.visible = tempSongs[i].isFav;
// fp.updateScore(0);
var maxTimer:Float = Math.min(i, 4);
new FlxTimer().start((1 / 24) * maxTimer, function(doShit) {
funnyMenu.doJumpIn = true;
});
new FlxTimer().start((0.09 * maxTimer) + 0.85, function(lerpTmr) {
funnyMenu.doLerp = true;
});
if (!force)
{
new FlxTimer().start(((0.20 * maxTimer) / (1 + maxTimer)) + 0.75, function(swagShi) {
funnyMenu.songText.visible = true;
funnyMenu.alpha = 1;
});
}
else
{
funnyMenu.songText.visible = true;
funnyMenu.alpha = 1;
}
funnyMenu.initJumpIn(Math.min(i, 4), force);
grpCapsules.add(funnyMenu);
@ -831,66 +838,7 @@ class FreeplayState extends MusicBeatSubState
{
// if (Assets.exists())
var poop:String = songs[curSelected].songName.toLowerCase();
// does not work properly, always just accidentally sets it to normal anyways!
/* if (!Assets.exists(Paths.json(songs[curSelected].songName + '/' + poop)))
{
// defaults to normal if HARD / EASY doesn't exist
// does not account if NORMAL doesn't exist!
FlxG.log.warn("CURRENT DIFFICULTY IS NOT CHARTED, DEFAULTING TO NORMAL!");
poop = Highscore.formatSong(songs[curSelected].songName.toLowerCase(), 1);
curDifficulty = 1;
}*/
PlayStatePlaylist.isStoryMode = false;
var songId:String = songs[curSelected].songName.toLowerCase();
var targetSong:Song = SongRegistry.instance.fetchEntry(songId);
var targetDifficulty:String = switch (curDifficulty)
{
case 0:
'easy';
case 1:
'normal';
case 2:
'hard';
default: 'normal';
};
// TODO: Implement additional difficulties into the interface properly.
if (FlxG.keys.pressed.E)
{
targetDifficulty = 'erect';
}
// TODO: Implement Pico into the interface properly.
var targetCharacter:String = 'bf';
if (FlxG.keys.pressed.P)
{
targetCharacter = 'pico';
}
PlayStatePlaylist.campaignId = songs[curSelected].levelId;
// Visual and audio effects.
FlxG.sound.play(Paths.sound('confirmMenu'));
dj.confirm();
if (targetSong != null)
{
// Load and cache the song's charts.
// TODO: Do this in the loading state.
targetSong.cacheCharts(true);
}
new FlxTimer().start(1, function(tmr:FlxTimer) {
LoadingState.loadAndSwitchState(new PlayState(
{
targetSong: targetSong,
targetDifficulty: targetDifficulty,
targetCharacter: targetCharacter,
}), true);
});
grpCapsules.members[curSelected].onConfirm();
}
}
@ -942,6 +890,62 @@ class FreeplayState extends MusicBeatSubState
}
}
function capsuleOnConfirmDefault():Void
{
var poop:String = songs[curSelected].songName.toLowerCase();
// does not work properly, always just accidentally sets it to normal anyways!
/* if (!Assets.exists(Paths.json(songs[curSelected].songName + '/' + poop)))
{
// defaults to normal if HARD / EASY doesn't exist
// does not account if NORMAL doesn't exist!
FlxG.log.warn("CURRENT DIFFICULTY IS NOT CHARTED, DEFAULTING TO NORMAL!");
poop = Highscore.formatSong(songs[curSelected].songName.toLowerCase(), 1);
curDifficulty = 1;
}*/
PlayStatePlaylist.isStoryMode = false;
var targetSong:Song = SongDataParser.fetchSong(songs[curSelected].songName.toLowerCase());
var targetDifficulty:String = switch (curDifficulty)
{
case 0:
'easy';
case 1:
'normal';
case 2:
'hard';
default: 'normal';
};
// TODO: Implement additional difficulties into the interface properly.
if (FlxG.keys.pressed.E)
{
targetDifficulty = 'erect';
}
// TODO: Implement Pico into the interface properly.
var targetCharacter:String = 'bf';
if (FlxG.keys.pressed.P)
{
targetCharacter = 'pico';
}
PlayStatePlaylist.campaignId = songs[curSelected].levelId;
// Visual and audio effects.
FlxG.sound.play(Paths.sound('confirmMenu'));
dj.confirm();
new FlxTimer().start(1, function(tmr:FlxTimer) {
LoadingState.loadAndSwitchState(new PlayState(
{
targetSong: targetSong,
targetDifficulty: targetDifficulty,
targetCharacter: targetCharacter,
}), true);
});
}
function changeSelection(change:Int = 0)
{
// fp.updateScore(12345);

View file

@ -4,6 +4,8 @@ import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxGroup;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import flixel.tweens.FlxTween;
import flixel.tweens.FlxEase;
class LetterSort extends FlxTypedSpriteGroup<FreeplayLetter>
{
@ -25,6 +27,7 @@ class LetterSort extends FlxTypedSpriteGroup<FreeplayLetter>
for (i in 0...5)
{
var letter:FreeplayLetter = new FreeplayLetter(i * 80, 0, i);
letter.ogY = y;
add(letter);
letters.push(letter);
@ -43,7 +46,7 @@ class LetterSort extends FlxTypedSpriteGroup<FreeplayLetter>
rightArrow.animation.play("arrow");
add(rightArrow);
// changeSelection(-3);
changeSelection(0);
}
override function update(elapsed:Float)
@ -56,8 +59,12 @@ class LetterSort extends FlxTypedSpriteGroup<FreeplayLetter>
public function changeSelection(diff:Int = 0)
{
curSelection += diff;
if (curSelection < 0) curSelection = letters.length - 1;
if (curSelection >= letters.length) curSelection = 0;
for (letter in letters)
letter.changeLetter(diff);
letter.changeLetter(diff, curSelection);
if (changeSelectionCallback != null) changeSelectionCallback(letters[2].arr[letters[2].curLetter]); // bullshit and long lol!
}
@ -69,16 +76,17 @@ class FreeplayLetter extends FlxSprite
public var curLetter:Int = 0;
public var ogY:Float = 0;
public function new(x:Float, y:Float, ?letterInd:Int)
{
super(x, y);
frames = Paths.getSparrowAtlas("freeplay/letterStuff");
var alphabet:String = "abcdefghijklmnopqrstuvwxyz";
arr = alphabet.split("");
arr.insert(0, "#");
arr.insert(0, "ALL");
arr.insert(0, "#");
arr.insert(0, "fav");
for (str in arr)
@ -96,7 +104,7 @@ class FreeplayLetter extends FlxSprite
}
}
public function changeLetter(diff:Int = 0)
public function changeLetter(diff:Int = 0, ?curSelection:Int)
{
curLetter += diff;

View file

@ -7,6 +7,7 @@ import flixel.group.FlxSpriteGroup;
import flixel.math.FlxMath;
import flixel.math.FlxPoint;
import flixel.text.FlxText;
import flixel.util.FlxTimer;
class SongMenuItem extends FlxSpriteGroup
{
@ -25,6 +26,8 @@ class SongMenuItem extends FlxSpriteGroup
public var doJumpOut:Bool = false;
public var onConfirm:Void->Void;
public function new(x:Float, y:Float, song:String)
{
super(x, y);
@ -65,6 +68,30 @@ class SongMenuItem extends FlxSpriteGroup
public final realScaled:Float = 0.8;
public function initJumpIn(maxTimer:Float, ?force:Bool):Void
{
new FlxTimer().start((1 / 24) * maxTimer, function(doShit) {
doJumpIn = true;
});
new FlxTimer().start((0.09 * maxTimer) + 0.85, function(lerpTmr) {
doLerp = true;
});
if (!force)
{
new FlxTimer().start(((0.20 * maxTimer) / (1 + maxTimer)) + 0.75, function(swagShi) {
songText.visible = true;
alpha = 1;
});
}
else
{
songText.visible = true;
alpha = 1;
}
}
override function update(elapsed:Float)
{
if (doJumpIn)