fixed bullshit

This commit is contained in:
Cameron Taylor 2020-10-06 18:56:14 -07:00
parent 567a7af392
commit 320a760d82
3 changed files with 85 additions and 3 deletions

74
source/LatencyState.hx Normal file
View File

@ -0,0 +1,74 @@
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.text.FlxText;
class LatencyState extends FlxState
{
var offsetText:FlxText;
var noteGrp:FlxTypedGroup<Note>;
var strumLine:FlxSprite;
override function create()
{
FlxG.sound.playMusic('assets/sounds/soundTest' + TitleState.soundExt);
noteGrp = new FlxTypedGroup<Note>();
add(noteGrp);
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);
Conductor.changeBPM(120);
super.create();
}
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)
{
daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * 0.45);
daNote.x = strumLine.x + 30;
if (daNote.y < strumLine.y)
daNote.kill();
});
super.update(elapsed);
}
}

View File

@ -19,10 +19,13 @@ class Note extends FlxSprite
public static var swagWidth:Float = 160 * 0.7;
public function new(strumTime:Float, noteData:Int, prevNote:Note)
public function new(strumTime:Float, noteData:Int, ?prevNote:Note)
{
super();
if (prevNote == null)
prevNote = this;
this.prevNote = prevNote;
x += 50;

View File

@ -18,9 +18,14 @@ import flixel.util.FlxTimer;
class TitleState extends FlxTransitionableState
{
static var initialized:Bool = false;
static public var soundExt:String = ".mp3";
override public function create():Void
{
#if (!web)
TitleState.soundExt = '.ogg';
#end
super.create();
if (!initialized)
@ -64,7 +69,7 @@ class TitleState extends FlxTransitionableState
FlxTween.tween(logoBl, {y: logoBl.y + 50}, 0.6, {ease: FlxEase.quadInOut, type: PINGPONG});
FlxTween.tween(logo, {y: logoBl.y + 50}, 0.6, {ease: FlxEase.quadInOut, type: PINGPONG, startDelay: 0.1});
FlxG.sound.playMusic('assets/music/title.mp3', 0, false);
FlxG.sound.playMusic('assets/music/title' + TitleState.soundExt, 0, false);
FlxG.sound.music.fadeIn(4, 0, 0.7);
}
@ -84,7 +89,7 @@ class TitleState extends FlxTransitionableState
{
FlxG.switchState(new PlayState());
});
FlxG.sound.play('assets/music/titleShoot.mp3', 0.7);
FlxG.sound.play('assets/music/titleShoot' + TitleState.soundExt, 0.7);
}
super.update(elapsed);