From 87d0b3607040756bc22d4683db17c78a824b76eb Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 19 Oct 2020 18:59:00 -0700 Subject: [PATCH] re added sustain notes lol --- source/ChartingState.hx | 22 ++++++++++++---------- source/Note.hx | 26 ++++++++++++++------------ source/PlayState.hx | 35 +++++++++++++++++++++++++++-------- 3 files changed, 53 insertions(+), 30 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 5392bccd9..3fe3bc38d 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -370,6 +370,17 @@ class ChartingState extends MusicBeatState } }); } + else + { + if (FlxG.mouse.x > gridBG.x + && FlxG.mouse.x < gridBG.x + gridBG.width + && FlxG.mouse.y > gridBG.y + && FlxG.mouse.y < gridBG.y + (GRID_SIZE * _song.notes[curSection].lengthInSteps)) + { + FlxG.log.add('added note'); + addNote(); + } + } } if (FlxG.mouse.x > gridBG.x @@ -382,15 +393,6 @@ class ChartingState extends MusicBeatState dummyArrow.y = FlxG.mouse.y; else dummyArrow.y = Math.floor(FlxG.mouse.y / GRID_SIZE) * GRID_SIZE; - - if (FlxG.mouse.justPressed) - { - if (!FlxG.mouse.overlaps(curRenderedNotes)) - { - FlxG.log.add('added note'); - addNote(); - } - } } if (FlxG.keys.justPressed.ENTER) @@ -587,7 +589,7 @@ class ChartingState extends MusicBeatState { for (i in _song.notes[curSection].sectionNotes) { - if (i.strumTime == note.strumTime && i.noteData % 4 == note.noteData) + if (i[0] == note.strumTime && i[1] % 4 == note.noteData) { FlxG.log.add('FOUND EVIL NUMBER'); _song.notes[curSection].sectionNotes.remove(i); diff --git a/source/Note.hx b/source/Note.hx index 5ea093e49..35f2dc851 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -16,6 +16,7 @@ class Note extends FlxSprite public var prevNote:Note; public var sustainLength:Float = 0; + public var isSustainNote:Bool = false; public var noteScore:Float = 1; @@ -25,7 +26,7 @@ class Note extends FlxSprite public static var BLUE_NOTE:Int = 1; public static var RED_NOTE:Int = 3; - public function new(strumTime:Float, noteData:Int, ?prevNote:Note) + public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false) { super(); @@ -33,6 +34,7 @@ class Note extends FlxSprite prevNote = this; this.prevNote = prevNote; + isSustainNote = sustainNote; x += 50; this.strumTime = strumTime; @@ -78,7 +80,7 @@ class Note extends FlxSprite trace(prevNote); - if (noteData < 0 && prevNote != null) + if (isSustainNote && prevNote != null) { noteScore * 0.2; alpha = 0.6; @@ -87,13 +89,13 @@ class Note extends FlxSprite switch (noteData) { - case -1: + case 2: animation.play('greenholdend'); - case -2: + case 3: animation.play('redholdend'); - case -3: + case 1: animation.play('blueholdend'); - case -4: + case 0: animation.play('purpleholdend'); } @@ -101,22 +103,22 @@ class Note extends FlxSprite x -= width / 2; - if (prevNote.noteData < 0) + if (prevNote.isSustainNote) { switch (prevNote.noteData) { - case -1: + case 2: prevNote.animation.play('greenhold'); - case -2: + case 3: prevNote.animation.play('redhold'); - case -3: + case 1: prevNote.animation.play('bluehold'); - case -4: + case 0: prevNote.animation.play('purplehold'); } prevNote.offset.y = -19; - prevNote.scale.y *= 2.25; + prevNote.scale.y *= (2.25 * PlayState.SONG.speed); // prevNote.setGraphicSize(); } } diff --git a/source/PlayState.hx b/source/PlayState.hx index d24fcfb49..3ccb642e6 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -274,8 +274,8 @@ class PlayState extends MusicBeatState sectionScores[0].push(0); sectionScores[1].push(0); - var daStrumTime:Float = songNotes.strumTime; - var daNoteData:Int = Std.int(songNotes.noteData % 4); + var daStrumTime:Float = songNotes[0]; + var daNoteData:Int = Std.int(songNotes[1] % 4); var gottaHitNote:Bool = section.mustHitSection; @@ -291,11 +291,30 @@ class PlayState extends MusicBeatState oldNote = null; var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote); - swagNote.sustainLength = songNotes.sustainLength; + swagNote.sustainLength = songNotes[2]; swagNote.scrollFactor.set(0, 0); + var susLength:Float = swagNote.sustainLength; + + susLength = susLength / Conductor.stepCrochet; unspawnNotes.push(swagNote); + for (susNote in 0...Math.floor(susLength)) + { + oldNote = unspawnNotes[Std.int(unspawnNotes.length - 1)]; + + var sustainNote:Note = new Note(daStrumTime + (Conductor.stepCrochet * susNote), daNoteData, oldNote, true); + sustainNote.scrollFactor.set(); + unspawnNotes.push(sustainNote); + + sustainNote.mustPress = gottaHitNote; + + if (sustainNote.mustPress) + { + sustainNote.x += FlxG.width / 2; // general offset + } + } + swagNote.mustPress = gottaHitNote; if (swagNote.mustPress) @@ -891,21 +910,21 @@ class PlayState extends MusicBeatState { notes.forEach(function(daNote:Note) { - if (daNote.canBeHit && daNote.mustPress) + if (daNote.canBeHit && daNote.mustPress && daNote.isSustainNote) { switch (daNote.noteData) { // NOTES YOU ARE HOLDING - case -1: + case 2: if (up && daNote.prevNote.wasGoodHit) goodNoteHit(daNote); - case -2: + case 3: if (right && daNote.prevNote.wasGoodHit) goodNoteHit(daNote); - case -3: + case 1: if (down && daNote.prevNote.wasGoodHit) goodNoteHit(daNote); - case -4: + case 0: if (left && daNote.prevNote.wasGoodHit) goodNoteHit(daNote); }