1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-26 15:07:14 +00:00

sequencer in progress

This commit is contained in:
Cameron Taylor 2020-10-09 21:22:26 -07:00
parent d528967efc
commit eb47d38047
2 changed files with 65 additions and 18 deletions

View file

@ -2,6 +2,7 @@
"lineEnds": {
"leftCurly": "both",
"rightCurly": "both",
"emptyCurly": "break",
"objectLiteralCurly": {
"leftCurly": "after"
}

View file

@ -2,7 +2,10 @@ package;
import flixel.FlxG;
import flixel.FlxState;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.ui.FlxButton;
import flixel.ui.FlxSpriteButton;
import flixel.util.FlxColor;
import haxe.Json;
import openfl.events.Event;
import openfl.events.IOErrorEvent;
@ -13,13 +16,61 @@ import openfl.net.FileReference;
class ChartingState extends MusicBeatState
{
var _file:FileReference;
var sequencer:FlxTypedGroup<FlxSpriteButton>;
var notes:Array<Dynamic> = [];
override function create()
{
var saveButton:FlxButton = new FlxButton(0, 0, "Save", function()
{
// bullshit
saveLevel();
});
saveButton.screenCenter();
add(saveButton);
createStepChart();
super.create();
}
function createStepChart()
{
sequencer = new FlxTypedGroup<FlxSpriteButton>();
add(sequencer);
for (r in 0...2)
{
notes.push([]);
for (i in 0...16)
{
notes[r].push(false);
var seqBtn:FlxSpriteButton = new FlxSpriteButton((35 * r) + 10, (35 * i) + 50, null, function()
{
notes[r][i] = !notes[r][i];
});
seqBtn.makeGraphic(30, 30, FlxColor.WHITE);
seqBtn.ID = i + (16 * r);
sequencer.add(seqBtn);
}
}
}
override function update(elapsed:Float)
{
sequencer.forEach(function(spr:FlxSpriteButton)
{
if (notes[Std.int(spr.ID / 16)][spr.ID % 16])
spr.alpha = 1;
else
spr.alpha = 0.5;
});
super.update(elapsed);
}
private function saveLevel()
{
var json = {
"song": "Bopeebo",
"bpm": 100,
@ -36,11 +87,6 @@ class ChartingState extends MusicBeatState
_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
_file.save(data, json.song + ".json");
}
});
saveButton.screenCenter();
add(saveButton);
super.create();
}
function onSaveComplete(_):Void