updates to early window and health gain + work on waveform
This commit is contained in:
parent
05817e12ea
commit
5698b6859d
@ -131,6 +131,8 @@ class ChartingState extends MusicBeatState
|
|||||||
|
|
||||||
var camFollow:FlxObject;
|
var camFollow:FlxObject;
|
||||||
|
|
||||||
|
public var waveform:Waveform;
|
||||||
|
|
||||||
public static var latestChartVersion = "2";
|
public static var latestChartVersion = "2";
|
||||||
|
|
||||||
override function create()
|
override function create()
|
||||||
@ -315,6 +317,7 @@ class ChartingState extends MusicBeatState
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
trace(height);
|
trace(height);
|
||||||
|
|
||||||
gridBlackLine = new FlxSprite(gridBG.width / 2).makeGraphic(2, height, FlxColor.BLACK);
|
gridBlackLine = new FlxSprite(gridBG.width / 2).makeGraphic(2, height, FlxColor.BLACK);
|
||||||
@ -385,6 +388,23 @@ class ChartingState extends MusicBeatState
|
|||||||
|
|
||||||
|
|
||||||
add(sectionRenderes);
|
add(sectionRenderes);
|
||||||
|
|
||||||
|
// fuckin stupid ass bitch ass fucking waveform
|
||||||
|
/*if (PlayState.isSM)
|
||||||
|
{
|
||||||
|
waveform = new Waveform(0,0,PlayState.pathToSm + "/" + PlayState.sm.header.MUSIC,height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_song.needsVoices)
|
||||||
|
waveform = new Waveform(0,0,Paths.voices(_song.song),height);
|
||||||
|
else
|
||||||
|
waveform = new Waveform(0,0,Paths.inst(_song.song),height);
|
||||||
|
}
|
||||||
|
|
||||||
|
waveform.drawWaveform();
|
||||||
|
add(waveform);
|
||||||
|
*/
|
||||||
add(dummyArrow);
|
add(dummyArrow);
|
||||||
add(strumLine);
|
add(strumLine);
|
||||||
add(lines);
|
add(lines);
|
||||||
|
@ -61,6 +61,8 @@ class GameplayCustomizeState extends MusicBeatState
|
|||||||
camHUD.bgColor.alpha = 0;
|
camHUD.bgColor.alpha = 0;
|
||||||
FlxG.cameras.add(camHUD);
|
FlxG.cameras.add(camHUD);
|
||||||
|
|
||||||
|
camHUD.zoom = FlxG.save.data.zoom;
|
||||||
|
|
||||||
background.scrollFactor.set(0.9,0.9);
|
background.scrollFactor.set(0.9,0.9);
|
||||||
curt.scrollFactor.set(0.9,0.9);
|
curt.scrollFactor.set(0.9,0.9);
|
||||||
front.scrollFactor.set(0.9,0.9);
|
front.scrollFactor.set(0.9,0.9);
|
||||||
@ -116,7 +118,7 @@ class GameplayCustomizeState extends MusicBeatState
|
|||||||
generateStaticArrows(0);
|
generateStaticArrows(0);
|
||||||
generateStaticArrows(1);
|
generateStaticArrows(1);
|
||||||
|
|
||||||
text = new FlxText(5, FlxG.height + 40, 0, "Click and drag around gameplay elements to customize their positions.\nPress R to reset.\nPress Escape to go back.", 12);
|
text = new FlxText(5, FlxG.height + 40, 0, "Click and drag around gameplay elements to customize their positions.\nPress R to reset. +/- to change zoom.\nPress Escape to go back.", 12);
|
||||||
text.scrollFactor.set();
|
text.scrollFactor.set();
|
||||||
text.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
|
text.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
|
||||||
|
|
||||||
@ -164,6 +166,18 @@ class GameplayCustomizeState extends MusicBeatState
|
|||||||
for (i in strumLineNotes)
|
for (i in strumLineNotes)
|
||||||
i.y = strumLine.y;
|
i.y = strumLine.y;
|
||||||
|
|
||||||
|
if (FlxG.keys.pressed.PLUS)
|
||||||
|
{
|
||||||
|
FlxG.save.data.zoom += 0.1;
|
||||||
|
camHUD.zoom = FlxG.save.data.zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlxG.keys.pressed.MINUS)
|
||||||
|
{
|
||||||
|
FlxG.save.data.zoom -= 0.1;
|
||||||
|
camHUD.zoom = FlxG.save.data.zoom;
|
||||||
|
}
|
||||||
|
|
||||||
if (FlxG.mouse.overlaps(sick) && FlxG.mouse.justReleased)
|
if (FlxG.mouse.overlaps(sick) && FlxG.mouse.justReleased)
|
||||||
{
|
{
|
||||||
FlxG.save.data.changedHitX = sick.x;
|
FlxG.save.data.changedHitX = sick.x;
|
||||||
|
@ -112,6 +112,9 @@ class KadeEngineData
|
|||||||
if (FlxG.save.data.editor == null)
|
if (FlxG.save.data.editor == null)
|
||||||
FlxG.save.data.editor = true;
|
FlxG.save.data.editor = true;
|
||||||
|
|
||||||
|
if (FlxG.save.data.zoom == null)
|
||||||
|
FlxG.save.data.zoom = 1;
|
||||||
|
|
||||||
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
|
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
|
||||||
|
|
||||||
KeyBinds.gamepad = gamepad != null;
|
KeyBinds.gamepad = gamepad != null;
|
||||||
|
@ -83,12 +83,15 @@ class Note extends FlxSprite
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.strumTime = strumTime;
|
this.strumTime = strumTime;
|
||||||
rStrumTime = strumTime - (FlxG.save.data.offset + PlayState.songOffset);
|
|
||||||
#if sys
|
#if sys
|
||||||
if (PlayState.isSM)
|
if (PlayState.isSM)
|
||||||
{
|
{
|
||||||
rStrumTime = Math.round(rStrumTime + Std.parseFloat(PlayState.sm.header.OFFSET));
|
rStrumTime = strumTime;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
rStrumTime = (strumTime - FlxG.save.data.offset + PlayState.songOffset);
|
||||||
|
#else
|
||||||
|
rStrumTime = (strumTime - FlxG.save.data.offset + PlayState.songOffset);
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,25 +248,23 @@ class Note extends FlxSprite
|
|||||||
|
|
||||||
if (mustPress)
|
if (mustPress)
|
||||||
{
|
{
|
||||||
// ass
|
|
||||||
if (isSustainNote)
|
if (isSustainNote)
|
||||||
{
|
{
|
||||||
if (strumTime > Conductor.songPosition - (Conductor.safeZoneOffset * 1.5)
|
if (strumTime - Conductor.songPosition <= ((166 * Conductor.timeScale) * 0.5)
|
||||||
&& strumTime < Conductor.songPosition + (Conductor.safeZoneOffset * 0.5))
|
&& strumTime - Conductor.songPosition >= (-166 * Conductor.timeScale))
|
||||||
canBeHit = true;
|
canBeHit = true;
|
||||||
else
|
else
|
||||||
canBeHit = false;
|
canBeHit = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (strumTime > Conductor.songPosition - Conductor.safeZoneOffset
|
if (strumTime - Conductor.songPosition <= (166 * Conductor.timeScale)
|
||||||
&& strumTime < Conductor.songPosition + Conductor.safeZoneOffset)
|
&& strumTime - Conductor.songPosition >= (-166 * Conductor.timeScale))
|
||||||
canBeHit = true;
|
canBeHit = true;
|
||||||
else
|
else
|
||||||
canBeHit = false;
|
canBeHit = false;
|
||||||
}
|
}
|
||||||
|
if (strumTime - Conductor.songPosition < -166 && !wasGoodHit)
|
||||||
if (strumTime < Conductor.songPosition - Conductor.safeZoneOffset * Conductor.timeScale && !wasGoodHit)
|
|
||||||
tooLate = true;
|
tooLate = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -311,6 +311,7 @@ class PlayState extends MusicBeatState
|
|||||||
PlayStateChangeables.scrollSpeed = FlxG.save.data.scrollSpeed;
|
PlayStateChangeables.scrollSpeed = FlxG.save.data.scrollSpeed;
|
||||||
PlayStateChangeables.botPlay = FlxG.save.data.botplay;
|
PlayStateChangeables.botPlay = FlxG.save.data.botplay;
|
||||||
PlayStateChangeables.Optimize = FlxG.save.data.optimize;
|
PlayStateChangeables.Optimize = FlxG.save.data.optimize;
|
||||||
|
PlayStateChangeables.zoom = FlxG.save.data.zoom;
|
||||||
|
|
||||||
// pre lowercasing the song name (create)
|
// pre lowercasing the song name (create)
|
||||||
var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase();
|
var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase();
|
||||||
@ -397,6 +398,8 @@ class PlayState extends MusicBeatState
|
|||||||
FlxG.cameras.add(camSustains);
|
FlxG.cameras.add(camSustains);
|
||||||
FlxG.cameras.add(camNotes);
|
FlxG.cameras.add(camNotes);
|
||||||
|
|
||||||
|
camHUD.zoom = PlayStateChangeables.zoom;
|
||||||
|
|
||||||
FlxCamera.defaultCameras = [camGame];
|
FlxCamera.defaultCameras = [camGame];
|
||||||
|
|
||||||
persistentUpdate = true;
|
persistentUpdate = true;
|
||||||
@ -1613,6 +1616,9 @@ class PlayState extends MusicBeatState
|
|||||||
keys[data] = false;
|
keys[data] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var closestNotes:Array<Note> = [];
|
||||||
|
|
||||||
|
|
||||||
private function handleInput(evt:KeyboardEvent):Void
|
private function handleInput(evt:KeyboardEvent):Void
|
||||||
{ // this actually handles press inputs
|
{ // this actually handles press inputs
|
||||||
|
|
||||||
@ -1668,13 +1674,9 @@ class PlayState extends MusicBeatState
|
|||||||
var ana = new Ana(Conductor.songPosition, null, false, "miss", data);
|
var ana = new Ana(Conductor.songPosition, null, false, "miss", data);
|
||||||
|
|
||||||
var dataNotes = [];
|
var dataNotes = [];
|
||||||
notes.forEachAlive(function(daNote:Note)
|
for(i in closestNotes)
|
||||||
{
|
if (i.noteData == data)
|
||||||
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit && daNote.noteData == data)
|
dataNotes.push(i);
|
||||||
dataNotes.push(daNote);
|
|
||||||
}); // Collect notes that can be hit
|
|
||||||
|
|
||||||
dataNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); // sort by the earliest note
|
|
||||||
|
|
||||||
if (dataNotes.length != 0)
|
if (dataNotes.length != 0)
|
||||||
{
|
{
|
||||||
@ -1724,7 +1726,7 @@ class PlayState extends MusicBeatState
|
|||||||
ana.hit = false;
|
ana.hit = false;
|
||||||
ana.hitJudge = "shit";
|
ana.hitJudge = "shit";
|
||||||
ana.nearestNote = [];
|
ana.nearestNote = [];
|
||||||
health -= 0.10;
|
health -= 0.30;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2255,6 +2257,8 @@ class PlayState extends MusicBeatState
|
|||||||
perfectMode = false;
|
perfectMode = false;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (updateFrame == 4)
|
if (updateFrame == 4)
|
||||||
{
|
{
|
||||||
TimingStruct.clearTimings();
|
TimingStruct.clearTimings();
|
||||||
@ -2622,6 +2626,20 @@ class PlayState extends MusicBeatState
|
|||||||
|
|
||||||
if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null)
|
if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
closestNotes = [];
|
||||||
|
|
||||||
|
notes.forEachAlive(function(daNote:Note)
|
||||||
|
{
|
||||||
|
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit)
|
||||||
|
closestNotes.push(daNote);
|
||||||
|
}); // Collect notes that can be hit
|
||||||
|
|
||||||
|
closestNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime));
|
||||||
|
|
||||||
|
if (closestNotes.length != 0)
|
||||||
|
FlxG.watch.addQuick("Current Note",closestNotes[0].strumTime - Conductor.songPosition);
|
||||||
|
|
||||||
// Make sure Girlfriend cheers only for certain songs
|
// Make sure Girlfriend cheers only for certain songs
|
||||||
if (allowedToHeadbang)
|
if (allowedToHeadbang)
|
||||||
{
|
{
|
||||||
@ -3140,13 +3158,13 @@ class PlayState extends MusicBeatState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!daNote.isSustainNote)
|
if (!daNote.isSustainNote)
|
||||||
health -= 0.10;
|
health -= 0.20;
|
||||||
vocals.volume = 0;
|
vocals.volume = 0;
|
||||||
if (theFunne && !daNote.isSustainNote)
|
if (theFunne && !daNote.isSustainNote)
|
||||||
noteMiss(daNote.noteData, daNote);
|
noteMiss(daNote.noteData, daNote);
|
||||||
if (daNote.isParent)
|
if (daNote.isParent)
|
||||||
{
|
{
|
||||||
health -= 0.20; // give a health punishment for failing a LN
|
health -= 0.30; // give a health punishment for failing a LN
|
||||||
trace("hold fell over at the start");
|
trace("hold fell over at the start");
|
||||||
for (i in daNote.children)
|
for (i in daNote.children)
|
||||||
{
|
{
|
||||||
@ -3161,7 +3179,7 @@ class PlayState extends MusicBeatState
|
|||||||
&& daNote.sustainActive
|
&& daNote.sustainActive
|
||||||
&& daNote.spotInLine != daNote.parent.children.length)
|
&& daNote.spotInLine != daNote.parent.children.length)
|
||||||
{
|
{
|
||||||
health -= 0.20; // give a health punishment for failing a LN
|
health -= 0.30; // give a health punishment for failing a LN
|
||||||
trace("hold fell over at " + daNote.spotInLine);
|
trace("hold fell over at " + daNote.spotInLine);
|
||||||
for (i in daNote.parent.children)
|
for (i in daNote.parent.children)
|
||||||
{
|
{
|
||||||
@ -3178,14 +3196,14 @@ class PlayState extends MusicBeatState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!daNote.isSustainNote)
|
if (!daNote.isSustainNote)
|
||||||
health -= 0.10;
|
health -= 0.20;
|
||||||
vocals.volume = 0;
|
vocals.volume = 0;
|
||||||
if (theFunne && !daNote.isSustainNote)
|
if (theFunne && !daNote.isSustainNote)
|
||||||
noteMiss(daNote.noteData, daNote);
|
noteMiss(daNote.noteData, daNote);
|
||||||
|
|
||||||
if (daNote.isParent)
|
if (daNote.isParent)
|
||||||
{
|
{
|
||||||
health -= 0.20; // give a health punishment for failing a LN
|
health -= 0.30; // give a health punishment for failing a LN
|
||||||
trace("hold fell over at the start");
|
trace("hold fell over at the start");
|
||||||
for (i in daNote.children)
|
for (i in daNote.children)
|
||||||
{
|
{
|
||||||
@ -3201,7 +3219,7 @@ class PlayState extends MusicBeatState
|
|||||||
&& daNote.sustainActive
|
&& daNote.sustainActive
|
||||||
&& daNote.spotInLine != daNote.parent.children.length)
|
&& daNote.spotInLine != daNote.parent.children.length)
|
||||||
{
|
{
|
||||||
health -= 0.20; // give a health punishment for failing a LN
|
health -= 0.40; // give a health punishment for failing a LN
|
||||||
trace("hold fell over at " + daNote.spotInLine);
|
trace("hold fell over at " + daNote.spotInLine);
|
||||||
for (i in daNote.parent.children)
|
for (i in daNote.parent.children)
|
||||||
{
|
{
|
||||||
@ -3457,7 +3475,7 @@ class PlayState extends MusicBeatState
|
|||||||
score = -300;
|
score = -300;
|
||||||
combo = 0;
|
combo = 0;
|
||||||
misses++;
|
misses++;
|
||||||
health -= 0.06;
|
health -= 0.1;
|
||||||
ss = false;
|
ss = false;
|
||||||
shits++;
|
shits++;
|
||||||
if (FlxG.save.data.accuracyMod == 0)
|
if (FlxG.save.data.accuracyMod == 0)
|
||||||
@ -3465,7 +3483,7 @@ class PlayState extends MusicBeatState
|
|||||||
case 'bad':
|
case 'bad':
|
||||||
daRating = 'bad';
|
daRating = 'bad';
|
||||||
score = 0;
|
score = 0;
|
||||||
health -= 0.03;
|
health -= 0.06;
|
||||||
ss = false;
|
ss = false;
|
||||||
bads++;
|
bads++;
|
||||||
if (FlxG.save.data.accuracyMod == 0)
|
if (FlxG.save.data.accuracyMod == 0)
|
||||||
|
@ -5,4 +5,5 @@ class PlayStateChangeables
|
|||||||
public static var scrollSpeed:Float;
|
public static var scrollSpeed:Float;
|
||||||
public static var botPlay:Bool;
|
public static var botPlay:Bool;
|
||||||
public static var Optimize:Bool;
|
public static var Optimize:Bool;
|
||||||
|
public static var zoom:Float;
|
||||||
}
|
}
|
@ -119,7 +119,7 @@ class Ratings
|
|||||||
|
|
||||||
public static function checkRating(ms:Float, ts:Float)
|
public static function checkRating(ms:Float, ts:Float)
|
||||||
{
|
{
|
||||||
var rating = "sick";
|
var rating = "shit";
|
||||||
if (ms <= 166 * ts && ms >= 135 * ts)
|
if (ms <= 166 * ts && ms >= 135 * ts)
|
||||||
rating = "shit";
|
rating = "shit";
|
||||||
if (ms < 135 * ts && ms >= 90 * ts)
|
if (ms < 135 * ts && ms >= 90 * ts)
|
||||||
|
88
source/Waveform.hx
Normal file
88
source/Waveform.hx
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
import flixel.util.FlxColor;
|
||||||
|
import flixel.FlxG;
|
||||||
|
import openfl.geom.Rectangle;
|
||||||
|
import haxe.io.Bytes;
|
||||||
|
import lime.media.AudioBuffer;
|
||||||
|
import flixel.FlxSprite;
|
||||||
|
|
||||||
|
class Waveform extends FlxSprite
|
||||||
|
{
|
||||||
|
|
||||||
|
/// referenced from https://github.com/gedehari/HaxeFlixel-Waveform-Rendering/blob/master/source/PlayState.hx
|
||||||
|
/// by gedehari
|
||||||
|
|
||||||
|
public var buffer:AudioBuffer;
|
||||||
|
public var data:Bytes;
|
||||||
|
|
||||||
|
public function new(x:Int,y:Int, audioPath:String, height:Int)
|
||||||
|
{
|
||||||
|
super(x,y);
|
||||||
|
|
||||||
|
var path = StringTools.replace(audioPath, "songs:","");
|
||||||
|
|
||||||
|
trace("loading " + path);
|
||||||
|
|
||||||
|
buffer = AudioBuffer.fromFile(path);
|
||||||
|
|
||||||
|
trace("BPS: " + buffer.bitsPerSample + " - Channels: " + buffer.channels);
|
||||||
|
|
||||||
|
makeGraphic(height,350,FlxColor.TRANSPARENT);
|
||||||
|
|
||||||
|
angle = 90;
|
||||||
|
|
||||||
|
data = buffer.data.toBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function drawWaveform()
|
||||||
|
{
|
||||||
|
var index:Int = 0;
|
||||||
|
var drawIndex:Int = 0;
|
||||||
|
var samplesPerCollumn:Int = 600;
|
||||||
|
|
||||||
|
var min:Float = 0;
|
||||||
|
var max:Float = 0;
|
||||||
|
|
||||||
|
while ((index * 4) < (data.length - 1))
|
||||||
|
{
|
||||||
|
var byte:Int = data.getUInt16(index * 4);
|
||||||
|
|
||||||
|
if (byte > 65535 / 2)
|
||||||
|
byte -= 65535;
|
||||||
|
|
||||||
|
var sample:Float = (byte / 65535);
|
||||||
|
|
||||||
|
if (sample > 0)
|
||||||
|
{
|
||||||
|
if (sample > max)
|
||||||
|
max = sample;
|
||||||
|
}
|
||||||
|
else if (sample < 0)
|
||||||
|
{
|
||||||
|
if (sample < min)
|
||||||
|
min = sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((index % samplesPerCollumn) == 0)
|
||||||
|
{
|
||||||
|
// trace("min: " + min + ", max: " + max);
|
||||||
|
|
||||||
|
if (drawIndex > 350)
|
||||||
|
{
|
||||||
|
drawIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pixelsMin:Float = Math.abs(min * 300);
|
||||||
|
var pixelsMax:Float = max * 300;
|
||||||
|
|
||||||
|
pixels.fillRect(new Rectangle(drawIndex, x, 1, height), 0xFF000000);
|
||||||
|
pixels.fillRect(new Rectangle(drawIndex, y - pixelsMin, 1, pixelsMin + pixelsMax), FlxColor.WHITE);
|
||||||
|
drawIndex += 1;
|
||||||
|
|
||||||
|
min = 0;
|
||||||
|
max = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user