Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit eb47d38

Browse files
committed
sequencer in progress
1 parent d528967 commit eb47d38

File tree

2 files changed

+63
-16
lines changed

2 files changed

+63
-16
lines changed

hxformat.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"lineEnds": {
33
"leftCurly": "both",
44
"rightCurly": "both",
5+
"emptyCurly": "break",
56
"objectLiteralCurly": {
67
"leftCurly": "after"
78
}

source/ChartingState.hx

+62-16
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package;
22

33
import flixel.FlxG;
44
import flixel.FlxState;
5+
import flixel.group.FlxGroup.FlxTypedGroup;
56
import flixel.ui.FlxButton;
7+
import flixel.ui.FlxSpriteButton;
8+
import flixel.util.FlxColor;
69
import haxe.Json;
710
import openfl.events.Event;
811
import openfl.events.IOErrorEvent;
@@ -13,34 +16,77 @@ import openfl.net.FileReference;
1316
class ChartingState extends MusicBeatState
1417
{
1518
var _file:FileReference;
19+
var sequencer:FlxTypedGroup<FlxSpriteButton>;
20+
var notes:Array<Dynamic> = [];
1621

1722
override function create()
1823
{
1924
var saveButton:FlxButton = new FlxButton(0, 0, "Save", function()
2025
{
21-
// bullshit
26+
saveLevel();
27+
});
28+
saveButton.screenCenter();
29+
add(saveButton);
2230

23-
var json = {
24-
"song": "Bopeebo",
25-
"bpm": 100,
26-
"sections": 15
27-
};
31+
createStepChart();
2832

29-
var data:String = Json.stringify(json);
33+
super.create();
34+
}
3035

31-
if ((data != null) && (data.length > 0))
36+
function createStepChart()
37+
{
38+
sequencer = new FlxTypedGroup<FlxSpriteButton>();
39+
add(sequencer);
40+
41+
for (r in 0...2)
42+
{
43+
notes.push([]);
44+
for (i in 0...16)
3245
{
33-
_file = new FileReference();
34-
_file.addEventListener(Event.COMPLETE, onSaveComplete);
35-
_file.addEventListener(Event.CANCEL, onSaveCancel);
36-
_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
37-
_file.save(data, json.song + ".json");
46+
notes[r].push(false);
47+
var seqBtn:FlxSpriteButton = new FlxSpriteButton((35 * r) + 10, (35 * i) + 50, null, function()
48+
{
49+
notes[r][i] = !notes[r][i];
50+
});
51+
52+
seqBtn.makeGraphic(30, 30, FlxColor.WHITE);
53+
seqBtn.ID = i + (16 * r);
54+
sequencer.add(seqBtn);
3855
}
56+
}
57+
}
58+
59+
override function update(elapsed:Float)
60+
{
61+
sequencer.forEach(function(spr:FlxSpriteButton)
62+
{
63+
if (notes[Std.int(spr.ID / 16)][spr.ID % 16])
64+
spr.alpha = 1;
65+
else
66+
spr.alpha = 0.5;
3967
});
40-
saveButton.screenCenter();
41-
add(saveButton);
4268

43-
super.create();
69+
super.update(elapsed);
70+
}
71+
72+
private function saveLevel()
73+
{
74+
var json = {
75+
"song": "Bopeebo",
76+
"bpm": 100,
77+
"sections": 15
78+
};
79+
80+
var data:String = Json.stringify(json);
81+
82+
if ((data != null) && (data.length > 0))
83+
{
84+
_file = new FileReference();
85+
_file.addEventListener(Event.COMPLETE, onSaveComplete);
86+
_file.addEventListener(Event.CANCEL, onSaveCancel);
87+
_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
88+
_file.save(data, json.song + ".json");
89+
}
4490
}
4591

4692
function onSaveComplete(_):Void

0 commit comments

Comments
 (0)