From dd623ed22f59289b739a87cdbee48df70871adac Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 13 Oct 2020 18:44:07 -0700 Subject: [PATCH] almost got good prototyping shit in --- source/ChartingState.hx | 21 ++++++++++++++++++++- source/PlayState.hx | 5 +++++ source/Song.hx | 12 ++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 124a018d1..45ba065eb 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -57,6 +57,8 @@ class ChartingState extends MusicBeatState var sections:Array
= []; var gridBG:FlxSprite; + var oldSongData:Song; + override function create() { gridBG = FlxGridOverlay.create(GRID_SIZE, GRID_SIZE, GRID_SIZE * 8, GRID_SIZE * 16); @@ -66,6 +68,18 @@ class ChartingState extends MusicBeatState addSection(); + if (PlayState.SONG != null) + oldSongData = PlayState.SONG; + else + { + oldSongData = new Song(curSong, sections, Conductor.bpm, sections.length); + } + + curSong = oldSongData.song; + sections = oldSongData.notes; + + updateGrid(); + FlxG.sound.playMusic('assets/music/' + curSong + '.mp3', 0.6); FlxG.sound.music.pause(); FlxG.sound.music.onComplete = function() @@ -183,7 +197,7 @@ class ChartingState extends MusicBeatState if (FlxG.keys.justPressed.ENTER) { - PlayState.SONG = new Song(curSong, getNotes(), Conductor.bpm, sections.length); + PlayState.SONG = new Song(curSong, sections, Conductor.bpm, sections.length); FlxG.sound.music.stop(); FlxG.switchState(new PlayState()); } @@ -308,6 +322,11 @@ class ChartingState extends MusicBeatState private var daSpacing:Float = 0.3; + function loadLevel():Void + { + trace(oldSongData.notes); + } + function getNotes():Array { var noteData:Array = []; diff --git a/source/PlayState.hx b/source/PlayState.hx index 433a1ecf4..2bdb38cc9 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -427,6 +427,11 @@ class PlayState extends MusicBeatState openSubState(new PauseSubState()); } + if (FlxG.keys.justPressed.ESCAPE) + { + FlxG.switchState(new ChartingState()); + } + FlxG.watch.addQuick('VOL', vocals.amplitudeLeft); FlxG.watch.addQuick('VOLRight', vocals.amplitudeRight); diff --git a/source/Song.hx b/source/Song.hx index 7f39b4efe..bd4105b9b 100644 --- a/source/Song.hx +++ b/source/Song.hx @@ -6,9 +6,10 @@ import lime.utils.Assets; class Song { public var song:String; - public var notes:Array; + public var notes:Array
; public var bpm:Int; public var sections:Int; + public var sectionLengths:Array = []; public function new(song, notes, bpm, sections) { @@ -16,14 +17,20 @@ class Song this.notes = notes; this.bpm = bpm; this.sections = sections; + + for (i in 0...notes.length) + { + this.sectionLengths.push(notes[i]); + } } public static function loadFromJson(jsonInput:String):Song { - var daNotes:Array = []; + var daNotes:Array
= []; var daBpm:Int = 0; var daSections:Int = 0; var daSong:String = ''; + var daSectionLengths:Array = []; var songData = Json.parse(Assets.getText('assets/data/' + jsonInput + '/' + jsonInput + '.json')); @@ -31,6 +38,7 @@ class Song daSong = songData.song; daSections = songData.sections; daBpm = songData.bpm; + daSectionLengths = songData.sectionLengths; return new Song(daSong, daNotes, daBpm, daSections); }