diff --git a/Project.xml b/Project.xml
index 3eb374045..a4437fa7d 100644
--- a/Project.xml
+++ b/Project.xml
@@ -92,5 +92,5 @@
-
+
diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx
index 81366b3e1..a3517006b 100644
--- a/source/FreeplayState.hx
+++ b/source/FreeplayState.hx
@@ -23,12 +23,17 @@ class FreeplayState extends MusicBeatState
for (i in 0...songs.length)
{
- var songText:Alphabet = new Alphabet(40, (70 * i) + 30, songs[i], true, false);
+ var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i], true, false);
add(songText);
+ songText.x += 40;
+ // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
// songText.screenCenter(X);
}
+ FlxG.sound.playMusic('assets/music/title' + TitleState.soundExt, 0);
+ FlxG.sound.music.fadeIn(2, 0, 0.8);
selector = new FlxText();
+
selector.size = 40;
selector.text = ">";
add(selector);
diff --git a/source/GameOverSubstate.hx b/source/GameOverSubstate.hx
index 32e608346..1a7d89d58 100644
--- a/source/GameOverSubstate.hx
+++ b/source/GameOverSubstate.hx
@@ -7,7 +7,7 @@ import flixel.math.FlxPoint;
import flixel.util.FlxColor;
import flixel.util.FlxTimer;
-class GameOverSubstate extends FlxSubState
+class GameOverSubstate extends MusicBeatSubstate
{
var bf:Boyfriend;
var camFollow:FlxObject;
@@ -16,6 +16,8 @@ class GameOverSubstate extends FlxSubState
{
super();
+ Conductor.songPosition = 0;
+
bf = new Boyfriend(x, y);
add(bf);
@@ -23,6 +25,7 @@ class GameOverSubstate extends FlxSubState
add(camFollow);
FlxG.sound.play('assets/sounds/fnf_loss_sfx' + TitleState.soundExt);
+ Conductor.changeBPM(100);
// FlxG.camera.followLerp = 1;
// FlxG.camera.focusOn(FlxPoint.get(FlxG.width / 2, FlxG.height / 2));
@@ -50,6 +53,18 @@ class GameOverSubstate extends FlxSubState
{
FlxG.sound.playMusic('assets/music/gameOver' + TitleState.soundExt);
}
+
+ if (FlxG.sound.music.playing)
+ {
+ Conductor.songPosition = FlxG.sound.music.time;
+ }
+ }
+
+ override function beatHit()
+ {
+ super.beatHit();
+
+ FlxG.log.add('beat');
}
var isEnding:Bool = false;
diff --git a/source/MusicBeatSubstate.hx b/source/MusicBeatSubstate.hx
new file mode 100644
index 000000000..0e452e9cd
--- /dev/null
+++ b/source/MusicBeatSubstate.hx
@@ -0,0 +1,78 @@
+package;
+
+import flixel.FlxSubState;
+
+class MusicBeatSubstate extends FlxSubState
+{
+ public function new()
+ {
+ super();
+ }
+
+ private var lastBeat:Float = 0;
+ private var lastStep:Float = 0;
+
+ private var totalBeats:Int = 0;
+ private var totalSteps:Int = 0;
+
+ private var curStep:Int = 0;
+ private var curBeat:Int = 0;
+ private var controls(get, never):Controls;
+
+ inline function get_controls():Controls
+ return PlayerSettings.player1.controls;
+
+ override function create()
+ {
+ #if (!web)
+ TitleState.soundExt = '.ogg';
+ #end
+
+ super.create();
+ }
+
+ override function update(elapsed:Float)
+ {
+ everyStep();
+
+ updateCurStep();
+ curBeat = Math.round(curStep / 4);
+
+ super.update(elapsed);
+ }
+
+ /**
+ * CHECKS EVERY FRAME
+ */
+ private function everyStep():Void
+ {
+ if (Conductor.songPosition > lastStep + Conductor.stepCrochet - Conductor.safeZoneOffset
+ || Conductor.songPosition < lastStep + Conductor.safeZoneOffset)
+ {
+ if (Conductor.songPosition > lastStep + Conductor.stepCrochet)
+ {
+ stepHit();
+ }
+ }
+ }
+
+ private function updateCurStep():Void
+ {
+ curStep = Math.floor(Conductor.songPosition / Conductor.stepCrochet);
+ }
+
+ public function stepHit():Void
+ {
+ totalSteps += 1;
+ lastStep += Conductor.stepCrochet;
+
+ if (totalSteps % 4 == 0)
+ beatHit();
+ }
+
+ public function beatHit():Void
+ {
+ lastBeat += Conductor.crochet;
+ totalBeats += 1;
+ }
+}