mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-23 23:33:55 +00:00
charting tool WIP shit
This commit is contained in:
parent
29615f24f7
commit
3ea8df0557
|
@ -1,8 +1,10 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
import flixel.FlxG;
|
import flixel.FlxG;
|
||||||
|
import flixel.FlxSprite;
|
||||||
import flixel.FlxState;
|
import flixel.FlxState;
|
||||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||||
|
import flixel.text.FlxText;
|
||||||
import flixel.ui.FlxButton;
|
import flixel.ui.FlxButton;
|
||||||
import flixel.ui.FlxSpriteButton;
|
import flixel.ui.FlxSpriteButton;
|
||||||
import flixel.util.FlxColor;
|
import flixel.util.FlxColor;
|
||||||
|
@ -16,11 +18,18 @@ import openfl.net.FileReference;
|
||||||
class ChartingState extends MusicBeatState
|
class ChartingState extends MusicBeatState
|
||||||
{
|
{
|
||||||
var _file:FileReference;
|
var _file:FileReference;
|
||||||
var sequencer:FlxTypedGroup<FlxSpriteButton>;
|
var sequencer:FlxTypedGroup<DisplayNote>;
|
||||||
var notes:Array<Dynamic> = [];
|
var notes:Array<Dynamic> = [];
|
||||||
|
var bpmTxt:FlxText;
|
||||||
|
|
||||||
|
var strumLine:FlxSprite;
|
||||||
|
|
||||||
override function create()
|
override function create()
|
||||||
{
|
{
|
||||||
|
FlxG.sound.playMusic('assets/music/Fresh.mp3', 0.6);
|
||||||
|
FlxG.sound.music.pause();
|
||||||
|
Conductor.changeBPM(120);
|
||||||
|
|
||||||
var saveButton:FlxButton = new FlxButton(0, 0, "Save", function()
|
var saveButton:FlxButton = new FlxButton(0, 0, "Save", function()
|
||||||
{
|
{
|
||||||
saveLevel();
|
saveLevel();
|
||||||
|
@ -28,6 +37,12 @@ class ChartingState extends MusicBeatState
|
||||||
saveButton.screenCenter();
|
saveButton.screenCenter();
|
||||||
add(saveButton);
|
add(saveButton);
|
||||||
|
|
||||||
|
bpmTxt = new FlxText(20, 20);
|
||||||
|
add(bpmTxt);
|
||||||
|
|
||||||
|
strumLine = new FlxSprite(0, 50).makeGraphic(Std.int(FlxG.width / 2), 4);
|
||||||
|
add(strumLine);
|
||||||
|
|
||||||
createStepChart();
|
createStepChart();
|
||||||
|
|
||||||
super.create();
|
super.create();
|
||||||
|
@ -35,20 +50,24 @@ class ChartingState extends MusicBeatState
|
||||||
|
|
||||||
function createStepChart()
|
function createStepChart()
|
||||||
{
|
{
|
||||||
sequencer = new FlxTypedGroup<FlxSpriteButton>();
|
sequencer = new FlxTypedGroup<DisplayNote>();
|
||||||
add(sequencer);
|
add(sequencer);
|
||||||
|
|
||||||
for (r in 0...2)
|
for (r in 0...4)
|
||||||
{
|
{
|
||||||
notes.push([]);
|
notes.push([]);
|
||||||
for (i in 0...16)
|
for (i in 0...16)
|
||||||
{
|
{
|
||||||
notes[r].push(false);
|
notes[r].push(false);
|
||||||
var seqBtn:FlxSpriteButton = new FlxSpriteButton((35 * r) + 10, (35 * i) + 50, null, function()
|
var seqBtn:DisplayNote = new DisplayNote((35 * r) + 10, (35 * i) + 50, null, function()
|
||||||
{
|
{
|
||||||
notes[r][i] = !notes[r][i];
|
if (notes[r][i] == 0)
|
||||||
|
notes[r][i] = 1;
|
||||||
|
else
|
||||||
|
notes[r][i] = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
seqBtn.strumTime = Conductor.stepCrochet * i;
|
||||||
seqBtn.makeGraphic(30, 30, FlxColor.WHITE);
|
seqBtn.makeGraphic(30, 30, FlxColor.WHITE);
|
||||||
seqBtn.ID = i + (16 * r);
|
seqBtn.ID = i + (16 * r);
|
||||||
sequencer.add(seqBtn);
|
sequencer.add(seqBtn);
|
||||||
|
@ -58,17 +77,51 @@ class ChartingState extends MusicBeatState
|
||||||
|
|
||||||
override function update(elapsed:Float)
|
override function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
sequencer.forEach(function(spr:FlxSpriteButton)
|
Conductor.songPosition = FlxG.sound.music.time;
|
||||||
|
|
||||||
|
if (FlxG.sound.music.playing)
|
||||||
{
|
{
|
||||||
if (notes[Std.int(spr.ID / 16)][spr.ID % 16])
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FlxG.keys.pressed.W)
|
||||||
|
FlxG.sound.music.time -= 900 * FlxG.elapsed;
|
||||||
|
if (FlxG.keys.pressed.S)
|
||||||
|
FlxG.sound.music.time += 900 * FlxG.elapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlxG.keys.justPressed.SPACE)
|
||||||
|
{
|
||||||
|
if (FlxG.sound.music.playing)
|
||||||
|
{
|
||||||
|
FlxG.sound.music.pause();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
FlxG.sound.music.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlxG.keys.justPressed.UP)
|
||||||
|
Conductor.changeBPM(Conductor.bpm + 1);
|
||||||
|
if (FlxG.keys.justPressed.DOWN)
|
||||||
|
Conductor.changeBPM(Conductor.bpm - 1);
|
||||||
|
|
||||||
|
bpmTxt.text = "BPM: " + Conductor.bpm;
|
||||||
|
|
||||||
|
sequencer.forEach(function(spr:DisplayNote)
|
||||||
|
{
|
||||||
|
if (notes[Std.int(spr.ID / 16)][spr.ID % 16] != 0)
|
||||||
spr.alpha = 1;
|
spr.alpha = 1;
|
||||||
else
|
else
|
||||||
spr.alpha = 0.5;
|
spr.alpha = 0.5;
|
||||||
|
|
||||||
|
spr.y = (strumLine.y - (Conductor.songPosition - spr.strumTime) * daSpacing);
|
||||||
});
|
});
|
||||||
|
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var daSpacing:Float = 0.3;
|
||||||
|
|
||||||
private function saveLevel()
|
private function saveLevel()
|
||||||
{
|
{
|
||||||
var json = {
|
var json = {
|
||||||
|
|
14
source/DisplayNote.hx
Normal file
14
source/DisplayNote.hx
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package;
|
||||||
|
|
||||||
|
import flixel.FlxSprite;
|
||||||
|
import flixel.ui.FlxSpriteButton;
|
||||||
|
|
||||||
|
class DisplayNote extends FlxSpriteButton
|
||||||
|
{
|
||||||
|
public var strumTime:Float = 0;
|
||||||
|
|
||||||
|
public function new(x:Float, y:Float, label:FlxSprite, onClick:Void->Void)
|
||||||
|
{
|
||||||
|
super(x, y, label, onClick);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue