From 97921c7a9b1c98f1a1bd460146c12e79aa9dd16f Mon Sep 17 00:00:00 2001
From: Cameron Taylor <cameron.taylor.ninja@gmail.com>
Date: Sat, 3 Oct 2020 12:32:15 -0700
Subject: [PATCH] scores and dope shit

---
 Project.xml         |  6 +++--
 source/Note.hx      |  5 ++++
 source/PlayState.hx | 56 +++++++++++++++++++++++++++++++++++++++------
 3 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/Project.xml b/Project.xml
index 12f749f18..2260a76d2 100644
--- a/Project.xml
+++ b/Project.xml
@@ -27,7 +27,9 @@
 
 	<!-- _____________________________ Path Settings ____________________________ -->
 
-	<set name="BUILD_DIR" value="export" />
+	<set name="BUILD_DIR" value="export/debug" if="debug" />
+	<set name="BUILD_DIR" value="export/release" unless="debug" />
+
 	<classpath name="source" />
 	<assets path="assets" />
 
@@ -36,7 +38,7 @@
 	<haxelib name="flixel" />
 
 	<!--In case you want to use the addons package-->
-	<!--<haxelib name="flixel-addons" />-->
+	<haxelib name="flixel-addons" />
 
 	<!--In case you want to use the ui package-->
 	<!--<haxelib name="flixel-ui" />-->
diff --git a/source/Note.hx b/source/Note.hx
index d5f729494..43328e312 100644
--- a/source/Note.hx
+++ b/source/Note.hx
@@ -14,6 +14,8 @@ class Note extends FlxSprite
 	public var wasGoodHit:Bool = false;
 	public var prevNote:Note;
 
+	public var noteScore:Float = 1;
+
 	public function new(strumTime:Float, noteData:Int)
 	{
 		super();
@@ -43,7 +45,10 @@ class Note extends FlxSprite
 		}
 
 		if (noteData < 0)
+		{
+			noteScore * 0.2;
 			alpha = 0.6;
+		}
 	}
 
 	override function update(elapsed:Float)
diff --git a/source/PlayState.hx b/source/PlayState.hx
index 58fa28264..e252acfb1 100644
--- a/source/PlayState.hx
+++ b/source/PlayState.hx
@@ -6,6 +6,8 @@ import flixel.FlxState;
 import flixel.group.FlxGroup.FlxTypedGroup;
 import flixel.system.FlxSound;
 import flixel.text.FlxText;
+import flixel.tweens.FlxTween;
+import flixel.util.FlxTimer;
 import haxe.Json;
 import lime.utils.Assets;
 
@@ -26,6 +28,9 @@ class PlayState extends FlxState
 	private var notes:FlxTypedGroup<Note>;
 
 	private var strumLine:FlxSprite;
+	private var curSection:Int = 0;
+
+	private var sectionScores:Array<Dynamic> = [[], []];
 
 	override public function create()
 	{
@@ -42,6 +47,8 @@ class PlayState extends FlxState
 		strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
 		add(strumLine);
 
+		FlxG.worldBounds.set(0, 0, FlxG.width, FlxG.height);
+
 		super.create();
 	}
 
@@ -70,6 +77,9 @@ class PlayState extends FlxState
 
 				for (songNotes in dumbassSection)
 				{
+					sectionScores[0].push(0);
+					sectionScores[1].push(0);
+
 					if (songNotes != 0)
 					{
 						var daStrumTime:Float = (((daStep * Conductor.stepCrochet) + (Conductor.crochet * 8 * daBeats))
@@ -83,14 +93,16 @@ class PlayState extends FlxState
 						{
 							swagNote.mustPress = true;
 						}
+						else
+						{
+							sectionScores[0][daBeats] += swagNote.noteScore;
+						}
 
 						if (notes.members.length > 0)
 							swagNote.prevNote = notes.members[notes.members.length - 1];
 						else
 							swagNote.prevNote = swagNote;
 
-						trace(notes.members.length - 1);
-
 						notes.add(swagNote);
 					}
 
@@ -106,6 +118,8 @@ class PlayState extends FlxState
 
 	var bouncingSprite:FlxSprite;
 
+	var sectionScored:Bool = false;
+
 	override public function update(elapsed:Float)
 	{
 		super.update(elapsed);
@@ -113,8 +127,17 @@ class PlayState extends FlxState
 		Conductor.songPosition = FlxG.sound.music.time;
 		var playerTurn:Int = totalBeats % 8;
 
+		if (playerTurn == 7 && !sectionScored)
+		{
+			popUpScore();
+			sectionScored = true;
+		}
+
 		if (playerTurn < 4)
+		{
 			bouncingSprite = dad;
+			sectionScored = false;
+		}
 		else
 			bouncingSprite = boyfriend;
 
@@ -139,6 +162,25 @@ class PlayState extends FlxState
 		keyShit();
 	}
 
+	private function popUpScore():Void
+	{
+		var placement:String = sectionScores[1][curSection] + '/' + sectionScores[0][curSection];
+		var coolText:FlxText = new FlxText(0, 0, 0, placement, 32);
+		coolText.screenCenter();
+		coolText.x = FlxG.width * 0.75;
+		add(coolText);
+
+		FlxTween.tween(coolText, {alpha: 0}, 0.2, {
+			onComplete: function(tween:FlxTween)
+			{
+				coolText.kill();
+			},
+			startDelay: Conductor.crochet * 0.001
+		});
+
+		curSection += 1;
+	}
+
 	function keyShit():Void
 	{
 		// HOLDING
@@ -162,19 +204,15 @@ class PlayState extends FlxState
 					{
 						// NOTES YOU ARE HOLDING
 						case -1:
-							trace(daNote.prevNote.wasGoodHit);
 							if (up && daNote.prevNote.wasGoodHit)
 								goodNoteHit(daNote);
 						case -2:
-							trace(daNote.prevNote.wasGoodHit);
 							if (right && daNote.prevNote.wasGoodHit)
 								goodNoteHit(daNote);
 						case -3:
-							trace(daNote.prevNote.wasGoodHit);
 							if (down && daNote.prevNote.wasGoodHit)
 								goodNoteHit(daNote);
 						case -4:
-							trace(daNote.prevNote.wasGoodHit);
 							if (left && daNote.prevNote.wasGoodHit)
 								goodNoteHit(daNote);
 						case 1: // NOTES YOU JUST PRESSED
@@ -202,7 +240,11 @@ class PlayState extends FlxState
 
 	function goodNoteHit(note:Note):Void
 	{
-		note.wasGoodHit = true;
+		if (!note.wasGoodHit)
+		{
+			sectionScores[1][curSection] += note.noteScore;
+			note.wasGoodHit = true;
+		}
 	}
 
 	function everyBeat():Void