mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-04-15 08:54:37 +00:00
CHARTING SHIT IN PROGRESS
This commit is contained in:
parent
405f362a73
commit
5ecd641b13
1
assets/data/tutorial/Tutorial.json
Normal file
1
assets/data/tutorial/Tutorial.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"song":"Tutorial","bpm":100,"sections":13,"notes":[[],[[1875,10]],[[0,0],[1200,3]],[[0,0],[1200,3]],[[0,1],[0,2],[1200,1]],[[0,2],[1200,1]],[[0,0],[1200,2]],[[0,0],[1200,2]],[[0,1],[600,1],[1200,2]],[],[],[],[[1200,15]]]}
|
BIN
assets/music/Tutorial.mp3
Normal file
BIN
assets/music/Tutorial.mp3
Normal file
Binary file not shown.
|
@ -23,6 +23,8 @@ import openfl.events.IOErrorEvent;
|
||||||
import openfl.geom.Rectangle;
|
import openfl.geom.Rectangle;
|
||||||
import openfl.net.FileReference;
|
import openfl.net.FileReference;
|
||||||
|
|
||||||
|
using StringTools;
|
||||||
|
|
||||||
class ChartingState extends MusicBeatState
|
class ChartingState extends MusicBeatState
|
||||||
{
|
{
|
||||||
var _file:FileReference;
|
var _file:FileReference;
|
||||||
|
@ -34,23 +36,26 @@ class ChartingState extends MusicBeatState
|
||||||
* Array of notes showing when each section STARTS in STEPS
|
* Array of notes showing when each section STARTS in STEPS
|
||||||
* Usually rounded up??
|
* Usually rounded up??
|
||||||
*/
|
*/
|
||||||
var section:Int = 0;
|
var curSection:Int = 0;
|
||||||
|
|
||||||
|
var sectionInfo:Array<Dynamic>;
|
||||||
|
|
||||||
var bpmTxt:FlxText;
|
var bpmTxt:FlxText;
|
||||||
|
|
||||||
var strumLine:FlxSprite;
|
var strumLine:FlxSprite;
|
||||||
var curSong:String = 'Fresh';
|
var curSong:String = 'Tutorial';
|
||||||
var amountSteps:Int = 0;
|
var amountSteps:Int = 0;
|
||||||
var bullshitUI:FlxGroup;
|
var bullshitUI:FlxGroup;
|
||||||
|
|
||||||
var highlight:FlxSprite;
|
var highlight:FlxSprite;
|
||||||
var tooltipType:FlxUITooltipStyle = {titleWidth: 120, bodyWidth: 120, bodyOffset: new FlxPoint(5, 5)};
|
|
||||||
|
|
||||||
var GRID_SIZE:Int = 50;
|
var GRID_SIZE:Int = 40;
|
||||||
|
|
||||||
var dummyArrow:FlxSprite;
|
var dummyArrow:FlxSprite;
|
||||||
|
|
||||||
var sections:Array<Dynamic> = [[]];
|
var curRenderedNotes:FlxTypedGroup<Note>;
|
||||||
|
|
||||||
|
var sections:Array<Section> = [];
|
||||||
var gridBG:FlxSprite;
|
var gridBG:FlxSprite;
|
||||||
|
|
||||||
override function create()
|
override function create()
|
||||||
|
@ -58,6 +63,10 @@ class ChartingState extends MusicBeatState
|
||||||
gridBG = FlxGridOverlay.create(GRID_SIZE, GRID_SIZE, GRID_SIZE * 8, GRID_SIZE * 16);
|
gridBG = FlxGridOverlay.create(GRID_SIZE, GRID_SIZE, GRID_SIZE * 8, GRID_SIZE * 16);
|
||||||
add(gridBG);
|
add(gridBG);
|
||||||
|
|
||||||
|
curRenderedNotes = new FlxTypedGroup<Note>();
|
||||||
|
|
||||||
|
addSection();
|
||||||
|
|
||||||
FlxG.sound.playMusic('assets/music/' + curSong + '.mp3', 0.6);
|
FlxG.sound.playMusic('assets/music/' + curSong + '.mp3', 0.6);
|
||||||
FlxG.sound.music.pause();
|
FlxG.sound.music.pause();
|
||||||
FlxG.sound.music.onComplete = function()
|
FlxG.sound.music.onComplete = function()
|
||||||
|
@ -86,6 +95,8 @@ class ChartingState extends MusicBeatState
|
||||||
dummyArrow = new FlxSprite().makeGraphic(GRID_SIZE, GRID_SIZE);
|
dummyArrow = new FlxSprite().makeGraphic(GRID_SIZE, GRID_SIZE);
|
||||||
add(dummyArrow);
|
add(dummyArrow);
|
||||||
|
|
||||||
|
add(curRenderedNotes);
|
||||||
|
|
||||||
super.create();
|
super.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,15 +139,33 @@ class ChartingState extends MusicBeatState
|
||||||
{
|
{
|
||||||
Conductor.songPosition = FlxG.sound.music.time;
|
Conductor.songPosition = FlxG.sound.music.time;
|
||||||
|
|
||||||
dummyArrow.x = Math.floor(FlxG.mouse.x / GRID_SIZE) * GRID_SIZE;
|
strumLine.y = getYfromStrum(Conductor.songPosition % (Conductor.stepCrochet * 16));
|
||||||
if (FlxG.keys.pressed.SHIFT)
|
|
||||||
dummyArrow.y = FlxG.mouse.y;
|
|
||||||
else
|
|
||||||
dummyArrow.y = Math.floor(FlxG.mouse.y / GRID_SIZE) * GRID_SIZE;
|
|
||||||
|
|
||||||
if (FlxG.mouse.justPressed)
|
if (curBeat % 4 == 0)
|
||||||
{
|
{
|
||||||
addNote();
|
if (curStep > (sections[curSection].lengthInSteps * 2) * (curSection + 1))
|
||||||
|
{
|
||||||
|
if (sections[curSection + 1] == null)
|
||||||
|
{
|
||||||
|
addSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
changeSection(curSection + 1, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlxG.mouse.overlaps(gridBG))
|
||||||
|
{
|
||||||
|
dummyArrow.x = Math.floor(FlxG.mouse.x / GRID_SIZE) * GRID_SIZE;
|
||||||
|
if (FlxG.keys.pressed.SHIFT)
|
||||||
|
dummyArrow.y = FlxG.mouse.y;
|
||||||
|
else
|
||||||
|
dummyArrow.y = Math.floor(FlxG.mouse.y / GRID_SIZE) * GRID_SIZE;
|
||||||
|
|
||||||
|
if (FlxG.mouse.justPressed)
|
||||||
|
{
|
||||||
|
addNote();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FlxG.keys.justPressed.SPACE)
|
if (FlxG.keys.justPressed.SPACE)
|
||||||
|
@ -149,35 +178,121 @@ class ChartingState extends MusicBeatState
|
||||||
FlxG.sound.music.play();
|
FlxG.sound.music.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FlxG.keys.justPressed.R)
|
||||||
|
{
|
||||||
|
changeSection();
|
||||||
|
}
|
||||||
|
|
||||||
if (FlxG.keys.justPressed.UP)
|
if (FlxG.keys.justPressed.UP)
|
||||||
Conductor.changeBPM(Conductor.bpm + 1);
|
Conductor.changeBPM(Conductor.bpm + 1);
|
||||||
if (FlxG.keys.justPressed.DOWN)
|
if (FlxG.keys.justPressed.DOWN)
|
||||||
Conductor.changeBPM(Conductor.bpm - 1);
|
Conductor.changeBPM(Conductor.bpm - 1);
|
||||||
|
|
||||||
bpmTxt.text = "BPM: " + Conductor.bpm + "\nSection: " + section;
|
if (FlxG.keys.justPressed.RIGHT)
|
||||||
|
changeSection(curSection + 1);
|
||||||
|
if (FlxG.keys.justPressed.LEFT)
|
||||||
|
changeSection(curSection - 1);
|
||||||
|
|
||||||
|
bpmTxt.text = "BPM: " + Conductor.bpm + "\nSection: " + curSection;
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeSection(sec:Int = 0, ?updateMusic:Bool = true):Void
|
||||||
|
{
|
||||||
|
if (sections[sec] != null)
|
||||||
|
{
|
||||||
|
curSection = sec;
|
||||||
|
updateGrid();
|
||||||
|
|
||||||
|
if (updateMusic)
|
||||||
|
{
|
||||||
|
FlxG.sound.music.pause();
|
||||||
|
|
||||||
|
var daNum:Int = 0;
|
||||||
|
var daLength:Int = 0;
|
||||||
|
while (daNum <= sec)
|
||||||
|
{
|
||||||
|
daLength += sections[daNum].lengthInSteps * 2;
|
||||||
|
daNum++;
|
||||||
|
}
|
||||||
|
|
||||||
|
FlxG.sound.music.time = (daLength - (sections[sec].lengthInSteps * 2)) * Conductor.stepCrochet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateGrid():Void
|
||||||
|
{
|
||||||
|
while (curRenderedNotes.members.length > 0)
|
||||||
|
{
|
||||||
|
curRenderedNotes.remove(curRenderedNotes.members[0], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var sectionInfo:Array<Dynamic> = sections[curSection].notes;
|
||||||
|
|
||||||
|
for (i in sectionInfo)
|
||||||
|
{
|
||||||
|
var daNoteInfo = i[1];
|
||||||
|
|
||||||
|
switch (daNoteInfo)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
daNoteInfo = 4;
|
||||||
|
case 1:
|
||||||
|
daNoteInfo = 3;
|
||||||
|
case 2:
|
||||||
|
daNoteInfo = 1;
|
||||||
|
case 3:
|
||||||
|
daNoteInfo = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
var note:Note = new Note(i[0], daNoteInfo);
|
||||||
|
note.setGraphicSize(GRID_SIZE, GRID_SIZE);
|
||||||
|
note.updateHitbox();
|
||||||
|
note.x = Math.floor(i[1] * GRID_SIZE);
|
||||||
|
note.y = getYfromStrum(note.strumTime);
|
||||||
|
|
||||||
|
curRenderedNotes.add(note);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addSection(lengthInSteps:Int = 16):Void
|
||||||
|
{
|
||||||
|
sections.push(new Section(lengthInSteps));
|
||||||
|
}
|
||||||
|
|
||||||
private function addNote():Void
|
private function addNote():Void
|
||||||
{
|
{
|
||||||
sections[0].push(getStrumTime(dummyArrow.y));
|
sections[curSection].notes.push([getStrumTime(dummyArrow.y), Math.floor(FlxG.mouse.x / GRID_SIZE)]);
|
||||||
trace(getStrumTime(dummyArrow.y) + "ms");
|
updateGrid();
|
||||||
trace(Conductor.stepCrochet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStrumTime(yPos:Float):Float
|
function getStrumTime(yPos:Float):Float
|
||||||
{
|
{
|
||||||
return FlxMath.remapToRange(yPos, 0, gridBG.height, 0, 16 * Conductor.stepCrochet);
|
return FlxMath.remapToRange(yPos, gridBG.y, gridBG.y + gridBG.height, 0, 16 * Conductor.stepCrochet);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getYfromStrum(strumTime:Float):Float
|
||||||
|
{
|
||||||
|
return FlxMath.remapToRange(strumTime, 0, Conductor.stepCrochet * 16, gridBG.y, gridBG.y + gridBG.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private var daSpacing:Float = 0.3;
|
private var daSpacing:Float = 0.3;
|
||||||
|
|
||||||
private function saveLevel()
|
private function saveLevel()
|
||||||
{
|
{
|
||||||
|
var noteData:Array<Dynamic> = [];
|
||||||
|
|
||||||
|
for (i in sections)
|
||||||
|
{
|
||||||
|
noteData.push(i.notes);
|
||||||
|
}
|
||||||
|
|
||||||
var json = {
|
var json = {
|
||||||
"song": "Bopeebo",
|
"song": curSong,
|
||||||
"bpm": 100,
|
"bpm": Conductor.bpm,
|
||||||
"sections": 15
|
"sections": sections.length,
|
||||||
|
'notes': noteData
|
||||||
};
|
};
|
||||||
|
|
||||||
var data:String = Json.stringify(json);
|
var data:String = Json.stringify(json);
|
||||||
|
@ -188,7 +303,8 @@ class ChartingState extends MusicBeatState
|
||||||
_file.addEventListener(Event.COMPLETE, onSaveComplete);
|
_file.addEventListener(Event.COMPLETE, onSaveComplete);
|
||||||
_file.addEventListener(Event.CANCEL, onSaveCancel);
|
_file.addEventListener(Event.CANCEL, onSaveCancel);
|
||||||
_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
|
_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
|
||||||
_file.save(data, json.song + ".json");
|
// _file.save(data.trim(), json.song + ".json");
|
||||||
|
_file.browse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ class MusicBeatState extends FlxUIState
|
||||||
private var totalBeats:Int = 0;
|
private var totalBeats:Int = 0;
|
||||||
private var totalSteps:Int = 0;
|
private var totalSteps:Int = 0;
|
||||||
|
|
||||||
|
private var curStep:Int = 0;
|
||||||
|
private var curBeat:Int = 0;
|
||||||
|
|
||||||
override function create()
|
override function create()
|
||||||
{
|
{
|
||||||
super.create();
|
super.create();
|
||||||
|
@ -20,6 +23,9 @@ class MusicBeatState extends FlxUIState
|
||||||
{
|
{
|
||||||
everyStep();
|
everyStep();
|
||||||
|
|
||||||
|
curStep = Math.floor(Conductor.songPosition / Conductor.stepCrochet);
|
||||||
|
curBeat = Math.floor(curStep / 4);
|
||||||
|
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ using StringTools;
|
||||||
class PlayState extends MusicBeatState
|
class PlayState extends MusicBeatState
|
||||||
{
|
{
|
||||||
public static var curLevel:String = 'Bopeebo';
|
public static var curLevel:String = 'Bopeebo';
|
||||||
|
public static var SONG:Song = Song.loadFromJson('bopeebo');
|
||||||
|
|
||||||
private var vocals:FlxSound;
|
private var vocals:FlxSound;
|
||||||
|
|
||||||
|
|
16
source/Section.hx
Normal file
16
source/Section.hx
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package;
|
||||||
|
|
||||||
|
class Section
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* NOT ACTUAL NOTE DATA! Just holds strum time and which part of the chart it is!
|
||||||
|
*/
|
||||||
|
public var notes:Array<Dynamic> = [];
|
||||||
|
|
||||||
|
public var lengthInSteps:Int = 16;
|
||||||
|
|
||||||
|
public function new(lengthInSteps:Int = 16)
|
||||||
|
{
|
||||||
|
this.lengthInSteps = lengthInSteps;
|
||||||
|
}
|
||||||
|
}
|
37
source/Song.hx
Normal file
37
source/Song.hx
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package;
|
||||||
|
|
||||||
|
import haxe.Json;
|
||||||
|
import lime.utils.Assets;
|
||||||
|
|
||||||
|
class Song
|
||||||
|
{
|
||||||
|
public var song:String;
|
||||||
|
public var notes:Array<Dynamic>;
|
||||||
|
public var bpm:Int;
|
||||||
|
public var sections:Int;
|
||||||
|
|
||||||
|
public function new(song, notes, bpm, sections)
|
||||||
|
{
|
||||||
|
this.song = song;
|
||||||
|
this.notes = notes;
|
||||||
|
this.bpm = bpm;
|
||||||
|
this.sections = sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadFromJson(jsonInput:String):Song
|
||||||
|
{
|
||||||
|
var daNotes:Array<Dynamic> = [];
|
||||||
|
var daBpm:Int = 0;
|
||||||
|
var daSections:Int = 0;
|
||||||
|
var daSong:String = '';
|
||||||
|
|
||||||
|
var songData = Json.parse(Assets.getText('assets/data/' + jsonInput + '/' + jsonInput + '.json'));
|
||||||
|
|
||||||
|
daNotes = songData.notes;
|
||||||
|
daSong = songData.song;
|
||||||
|
daSections = songData.sections;
|
||||||
|
daBpm = songData.bpm;
|
||||||
|
|
||||||
|
return new Song(daSong, daNotes, daBpm, daSections);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue