2022-03-08 08:13:53 +00:00
|
|
|
package funkin;
|
2020-10-07 01:56:14 +00:00
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
2022-07-05 18:24:02 +00:00
|
|
|
import flixel.FlxSubState;
|
2020-10-07 01:56:14 +00:00
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
|
|
|
import flixel.text.FlxText;
|
2022-07-05 18:34:08 +00:00
|
|
|
import flixel.util.FlxColor;
|
|
|
|
import funkin.audiovis.PolygonSpectogram;
|
2020-10-07 01:56:14 +00:00
|
|
|
|
2022-07-05 18:24:02 +00:00
|
|
|
class LatencyState extends MusicBeatSubstate
|
2020-10-07 01:56:14 +00:00
|
|
|
{
|
|
|
|
var offsetText:FlxText;
|
|
|
|
var noteGrp:FlxTypedGroup<Note>;
|
|
|
|
var strumLine:FlxSprite;
|
|
|
|
|
2022-07-05 18:24:02 +00:00
|
|
|
var block:FlxSprite;
|
|
|
|
|
2020-10-07 01:56:14 +00:00
|
|
|
override function create()
|
|
|
|
{
|
2021-02-08 21:34:48 +00:00
|
|
|
FlxG.sound.playMusic(Paths.sound('soundTest'));
|
2020-10-07 01:56:14 +00:00
|
|
|
|
|
|
|
noteGrp = new FlxTypedGroup<Note>();
|
|
|
|
add(noteGrp);
|
|
|
|
|
2022-07-05 18:34:08 +00:00
|
|
|
var musSpec:PolygonSpectogram = new PolygonSpectogram(FlxG.sound.music, FlxColor.RED, FlxG.height, Math.floor(FlxG.height / 2));
|
|
|
|
musSpec.x += 170;
|
|
|
|
musSpec.scrollFactor.set();
|
|
|
|
musSpec.waveAmplitude = 50;
|
|
|
|
musSpec.realtimeVisLenght = 0.6;
|
|
|
|
// musSpec.visType = FREQUENCIES;
|
|
|
|
add(musSpec);
|
|
|
|
|
2022-07-05 18:24:02 +00:00
|
|
|
block = new FlxSprite().makeGraphic(100, 100);
|
|
|
|
add(block);
|
|
|
|
|
2020-10-07 01:56:14 +00:00
|
|
|
for (i in 0...32)
|
|
|
|
{
|
|
|
|
var note:Note = new Note(Conductor.crochet * i, 1);
|
|
|
|
noteGrp.add(note);
|
|
|
|
}
|
|
|
|
|
|
|
|
offsetText = new FlxText();
|
|
|
|
offsetText.screenCenter();
|
|
|
|
add(offsetText);
|
|
|
|
|
|
|
|
strumLine = new FlxSprite(FlxG.width / 2, 100).makeGraphic(FlxG.width, 5);
|
|
|
|
add(strumLine);
|
|
|
|
|
2022-04-18 23:36:09 +00:00
|
|
|
Conductor.bpm = 120;
|
2020-10-07 01:56:14 +00:00
|
|
|
|
|
|
|
super.create();
|
|
|
|
}
|
|
|
|
|
2022-07-05 18:24:02 +00:00
|
|
|
override function beatHit()
|
|
|
|
{
|
|
|
|
block.visible = !block.visible;
|
|
|
|
|
|
|
|
super.beatHit();
|
|
|
|
}
|
|
|
|
|
2020-10-07 01:56:14 +00:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
offsetText.text = "Offset: " + Conductor.offset + "ms";
|
|
|
|
|
|
|
|
Conductor.songPosition = FlxG.sound.music.time - Conductor.offset;
|
|
|
|
|
|
|
|
var multiply:Float = 1;
|
|
|
|
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
multiply = 10;
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.RIGHT)
|
|
|
|
Conductor.offset += 1 * multiply;
|
|
|
|
if (FlxG.keys.justPressed.LEFT)
|
|
|
|
Conductor.offset -= 1 * multiply;
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.SPACE)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.stop();
|
|
|
|
|
|
|
|
FlxG.resetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
noteGrp.forEach(function(daNote:Note)
|
|
|
|
{
|
2022-01-22 21:53:38 +00:00
|
|
|
daNote.y = (strumLine.y - (Conductor.songPosition - daNote.data.strumTime) * 0.45);
|
2020-10-07 01:56:14 +00:00
|
|
|
daNote.x = strumLine.x + 30;
|
|
|
|
|
|
|
|
if (daNote.y < strumLine.y)
|
2022-07-05 18:24:02 +00:00
|
|
|
daNote.alpha = 0.5;
|
|
|
|
|
|
|
|
if (daNote.y < 0 - daNote.height)
|
|
|
|
{
|
|
|
|
daNote.alpha = 1;
|
|
|
|
// daNote.data.strumTime += Conductor.crochet * 8;
|
|
|
|
}
|
2020-10-07 01:56:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
super.update(elapsed);
|
|
|
|
}
|
|
|
|
}
|