From c5d07c745f64e31045ec47570c9ef78619091a6d Mon Sep 17 00:00:00 2001
From: Cameron Taylor <cameron.taylor.ninja@gmail.com>
Date: Tue, 13 Oct 2020 18:23:22 -0700
Subject: [PATCH] NOTE DELETING

---
 source/ChartingState.hx | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/source/ChartingState.hx b/source/ChartingState.hx
index a45f1c36c..124a018d1 100644
--- a/source/ChartingState.hx
+++ b/source/ChartingState.hx
@@ -163,13 +163,28 @@ class ChartingState extends MusicBeatState
 
 			if (FlxG.mouse.justPressed)
 			{
-				addNote();
+				if (FlxG.mouse.overlaps(curRenderedNotes))
+				{
+					curRenderedNotes.forEach(function(note:Note)
+					{
+						if (FlxG.mouse.overlaps(note))
+						{
+							deleteNote(note);
+						}
+					});
+				}
+				else
+				{
+					FlxG.log.add('added note');
+					addNote();
+				}
 			}
 		}
 
 		if (FlxG.keys.justPressed.ENTER)
 		{
 			PlayState.SONG = new Song(curSong, getNotes(), Conductor.bpm, sections.length);
+			FlxG.sound.music.stop();
 			FlxG.switchState(new PlayState());
 		}
 
@@ -254,10 +269,24 @@ class ChartingState extends MusicBeatState
 		sections.push(new Section(lengthInSteps));
 	}
 
+	function deleteNote(note:Note):Void
+	{
+		for (i in sections[curSection].notes)
+		{
+			if (i[0] == note.strumTime && i[1] == note.noteData)
+			{
+				FlxG.log.add('FOUND EVIL NUMBER');
+				sections[curSection].notes.remove(i);
+			}
+		}
+
+		updateGrid();
+	}
+
 	private function addNote():Void
 	{
 		sections[curSection].notes.push([
-			getStrumTime(dummyArrow.y) + (curSection * (Conductor.stepCrochet * 32)),
+			Math.round(getStrumTime(dummyArrow.y) + (curSection * (Conductor.stepCrochet * 32))),
 			Math.floor(FlxG.mouse.x / GRID_SIZE)
 		]);