1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 19:33:36 +00:00
Funkin/source/funkin/play/components/PopUpStuff.hx

119 lines
3.2 KiB
Haxe
Raw Normal View History

package funkin.play.components;
import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.tweens.FlxTween;
import flixel.util.FlxDirection;
import funkin.graphics.FunkinSprite;
import funkin.play.PlayState;
2024-03-14 01:47:15 +00:00
import funkin.util.TimerUtil;
2024-06-20 03:47:11 +00:00
import funkin.util.EaseUtil;
2024-07-13 19:45:58 +00:00
import openfl.utils.Assets;
2024-07-16 17:53:12 +00:00
import funkin.data.notestyle.NoteStyleRegistry;
import funkin.play.notes.notestyle.NoteStyle;
@:nullSafety
2024-06-20 03:47:11 +00:00
class PopUpStuff extends FlxTypedGroup<FunkinSprite>
{
2024-07-13 19:45:58 +00:00
/**
* The current note style to use. This determines which graphics to display.
* For example, Week 6 uses the `pixel` note style, and mods can create their own.
2024-07-13 19:45:58 +00:00
*/
var noteStyle:NoteStyle;
2024-07-17 20:19:18 +00:00
override public function new(noteStyle:NoteStyle)
{
super();
2024-07-16 17:53:12 +00:00
this.noteStyle = noteStyle;
2024-07-13 19:45:58 +00:00
}
public function displayRating(daRating:Null<String>)
{
if (daRating == null) daRating = "good";
var rating:Null<FunkinSprite> = noteStyle.buildJudgementSprite(daRating);
if (rating == null) return;
rating.zIndex = 1000;
rating.x = (FlxG.width * 0.474);
rating.x -= rating.width / 2;
rating.y = (FlxG.camera.height * 0.45 - 60);
rating.y -= rating.height / 2;
var offsets = noteStyle.getJudgementSpriteOffsets(daRating);
rating.x += offsets[0];
rating.y += offsets[1];
rating.acceleration.y = 550;
rating.velocity.y -= FlxG.random.int(140, 175);
rating.velocity.x -= FlxG.random.int(0, 10);
add(rating);
var fadeEase = noteStyle.isJudgementSpritePixel(daRating) ? EaseUtil.stepped(2) : null;
FlxTween.tween(rating, {alpha: 0}, 0.2,
{
2023-06-08 20:30:45 +00:00
onComplete: function(tween:FlxTween) {
remove(rating, true);
rating.destroy();
},
2024-06-20 03:47:11 +00:00
startDelay: Conductor.instance.beatLengthMs * 0.001,
ease: fadeEase
});
}
public function displayCombo(combo:Int = 0):Void
{
var seperatedScore:Array<Int> = [];
var tempCombo:Int = combo;
while (tempCombo != 0)
{
seperatedScore.push(tempCombo % 10);
tempCombo = Std.int(tempCombo / 10);
}
while (seperatedScore.length < 3)
seperatedScore.push(0);
// seperatedScore.reverse();
var daLoop:Int = 1;
for (digit in seperatedScore)
{
var numScore:Null<FunkinSprite> = noteStyle.buildComboNumSprite(digit);
if (numScore == null) continue;
numScore.x = (FlxG.width * 0.507) - (36 * daLoop) - 65;
trace('numScore($daLoop) = ${numScore.x}');
numScore.y = (FlxG.camera.height * 0.44);
var offsets = noteStyle.getComboNumSpriteOffsets(digit);
numScore.x += offsets[0];
numScore.y += offsets[1];
numScore.acceleration.y = FlxG.random.int(250, 300);
numScore.velocity.y -= FlxG.random.int(130, 150);
numScore.velocity.x = FlxG.random.float(-5, 5);
add(numScore);
var fadeEase = noteStyle.isComboNumSpritePixel(digit) ? EaseUtil.stepped(2) : null;
FlxTween.tween(numScore, {alpha: 0}, 0.2,
{
2023-06-08 20:30:45 +00:00
onComplete: function(tween:FlxTween) {
remove(numScore, true);
numScore.destroy();
},
2024-06-20 03:47:11 +00:00
startDelay: Conductor.instance.beatLengthMs * 0.002,
ease: fadeEase
});
daLoop++;
}
2024-07-13 19:45:58 +00:00
}
}