2020-10-03 06:50:15 +00:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
2020-10-04 06:42:58 +00:00
|
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
2021-01-25 09:18:44 +00:00
|
|
|
import flixel.math.FlxMath;
|
2020-10-03 06:50:15 +00:00
|
|
|
import flixel.util.FlxColor;
|
2021-03-20 08:33:44 +00:00
|
|
|
import flixel.util.FlxTimer;
|
|
|
|
import shaderslmfao.ColorSwap;
|
2021-03-30 22:10:15 +00:00
|
|
|
import ui.PreferencesMenu;
|
2021-03-20 05:03:42 +00:00
|
|
|
|
|
|
|
using StringTools;
|
|
|
|
|
2021-02-10 20:18:14 +00:00
|
|
|
#if polymod
|
2021-01-25 09:18:44 +00:00
|
|
|
import polymod.format.ParseRules.TargetSignatureElement;
|
2021-02-10 20:18:14 +00:00
|
|
|
#end
|
2020-10-03 06:50:15 +00:00
|
|
|
|
|
|
|
class Note extends FlxSprite
|
|
|
|
{
|
2022-01-22 21:53:38 +00:00
|
|
|
public var data:NoteData = {
|
|
|
|
strumTime: 0,
|
|
|
|
sustainLength: 0,
|
|
|
|
altNote: false,
|
|
|
|
noteData: 0
|
|
|
|
};
|
2020-10-03 06:50:15 +00:00
|
|
|
|
|
|
|
public var mustPress:Bool = false;
|
2021-12-07 03:35:14 +00:00
|
|
|
public var followsTime:Bool = true; // used if you want the note to follow the time shit!
|
2020-10-03 06:50:15 +00:00
|
|
|
public var noteData:Int = 0;
|
2020-10-03 17:36:39 +00:00
|
|
|
public var canBeHit:Bool = false;
|
|
|
|
public var tooLate:Bool = false;
|
|
|
|
public var wasGoodHit:Bool = false;
|
|
|
|
public var prevNote:Note;
|
2021-04-10 22:23:56 +00:00
|
|
|
|
2021-04-08 01:29:32 +00:00
|
|
|
private var willMiss:Bool = false;
|
2020-10-03 06:50:15 +00:00
|
|
|
|
2021-04-10 22:23:56 +00:00
|
|
|
public var altNote:Bool = false;
|
|
|
|
public var invisNote:Bool = false;
|
|
|
|
|
2020-10-19 00:59:53 +00:00
|
|
|
public var sustainLength:Float = 0;
|
2020-10-20 01:59:00 +00:00
|
|
|
public var isSustainNote:Bool = false;
|
2020-10-19 00:59:53 +00:00
|
|
|
|
2021-03-21 18:45:46 +00:00
|
|
|
public var colorSwap:ColorSwap;
|
2020-10-03 19:32:15 +00:00
|
|
|
|
2020-10-04 08:38:21 +00:00
|
|
|
public static var swagWidth:Float = 160 * 0.7;
|
2020-10-14 02:12:31 +00:00
|
|
|
public static var PURP_NOTE:Int = 0;
|
|
|
|
public static var GREEN_NOTE:Int = 2;
|
|
|
|
public static var BLUE_NOTE:Int = 1;
|
|
|
|
public static var RED_NOTE:Int = 3;
|
2020-10-04 08:38:21 +00:00
|
|
|
|
2021-09-08 17:28:11 +00:00
|
|
|
// SCORING STUFF
|
|
|
|
public static var safeFrames:Int = 10;
|
|
|
|
public static var HIT_WINDOW:Float = (safeFrames / 60) * 1000; // 166.67 ms hit window
|
|
|
|
// anything above bad threshold is shit
|
|
|
|
public static var BAD_THRESHOLD:Float = 0.8; // 125ms , 8 frames
|
|
|
|
public static var GOOD_THRESHOLD:Float = 0.55; // 91.67ms , 5.5 frames
|
|
|
|
public static var SICK_THRESHOLD:Float = 0.2; // 33.33ms , 2 frames
|
|
|
|
|
2021-12-30 05:09:16 +00:00
|
|
|
public var noteSpeedMulti:Float = 1;
|
|
|
|
public var pastHalfWay:Bool = false;
|
|
|
|
|
2021-11-29 20:26:45 +00:00
|
|
|
// anything below sick threshold is sick
|
2021-03-21 18:45:46 +00:00
|
|
|
public static var arrowColors:Array<Float> = [1, 1, 1, 1];
|
|
|
|
|
2022-01-22 21:53:38 +00:00
|
|
|
public function new(strumTime:Float = 0, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false)
|
2020-10-03 06:50:15 +00:00
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
2020-10-07 01:56:14 +00:00
|
|
|
if (prevNote == null)
|
|
|
|
prevNote = this;
|
|
|
|
|
2020-10-05 05:13:12 +00:00
|
|
|
this.prevNote = prevNote;
|
2020-10-20 01:59:00 +00:00
|
|
|
isSustainNote = sustainNote;
|
2020-10-05 05:13:12 +00:00
|
|
|
|
2020-10-04 08:38:21 +00:00
|
|
|
x += 50;
|
2020-11-11 02:07:56 +00:00
|
|
|
// MAKE SURE ITS DEFINITELY OFF SCREEN?
|
|
|
|
y -= 2000;
|
2022-01-22 21:53:38 +00:00
|
|
|
data.strumTime = strumTime;
|
2020-10-03 17:36:39 +00:00
|
|
|
|
2020-10-03 06:50:15 +00:00
|
|
|
this.noteData = noteData;
|
|
|
|
|
2021-01-25 09:18:44 +00:00
|
|
|
var daStage:String = PlayState.curStage;
|
2020-10-04 06:42:58 +00:00
|
|
|
|
2021-01-25 09:18:44 +00:00
|
|
|
switch (daStage)
|
|
|
|
{
|
2021-02-13 22:39:31 +00:00
|
|
|
case 'school' | 'schoolEvil':
|
2021-02-08 21:34:48 +00:00
|
|
|
loadGraphic(Paths.image('weeb/pixelUI/arrows-pixels'), true, 17, 17);
|
2021-02-02 05:48:22 +00:00
|
|
|
|
|
|
|
animation.add('greenScroll', [6]);
|
|
|
|
animation.add('redScroll', [7]);
|
|
|
|
animation.add('blueScroll', [5]);
|
|
|
|
animation.add('purpleScroll', [4]);
|
|
|
|
|
|
|
|
if (isSustainNote)
|
|
|
|
{
|
2021-02-08 21:34:48 +00:00
|
|
|
loadGraphic(Paths.image('weeb/pixelUI/arrowEnds'), true, 7, 6);
|
2021-02-02 05:48:22 +00:00
|
|
|
|
|
|
|
animation.add('purpleholdend', [4]);
|
|
|
|
animation.add('greenholdend', [6]);
|
|
|
|
animation.add('redholdend', [7]);
|
|
|
|
animation.add('blueholdend', [5]);
|
|
|
|
|
|
|
|
animation.add('purplehold', [0]);
|
|
|
|
animation.add('greenhold', [2]);
|
|
|
|
animation.add('redhold', [3]);
|
|
|
|
animation.add('bluehold', [1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
setGraphicSize(Std.int(width * PlayState.daPixelZoom));
|
|
|
|
updateHitbox();
|
|
|
|
|
2021-01-25 09:18:44 +00:00
|
|
|
default:
|
2021-02-08 21:34:48 +00:00
|
|
|
frames = Paths.getSparrowAtlas('NOTE_assets');
|
2020-10-05 05:13:12 +00:00
|
|
|
|
2021-03-20 05:03:42 +00:00
|
|
|
animation.addByPrefix('greenScroll', 'green instance');
|
|
|
|
animation.addByPrefix('redScroll', 'red instance');
|
|
|
|
animation.addByPrefix('blueScroll', 'blue instance');
|
|
|
|
animation.addByPrefix('purpleScroll', 'purple instance');
|
2020-10-05 05:13:12 +00:00
|
|
|
|
2021-01-25 09:18:44 +00:00
|
|
|
animation.addByPrefix('purpleholdend', 'pruple end hold');
|
|
|
|
animation.addByPrefix('greenholdend', 'green hold end');
|
|
|
|
animation.addByPrefix('redholdend', 'red hold end');
|
|
|
|
animation.addByPrefix('blueholdend', 'blue hold end');
|
|
|
|
|
|
|
|
animation.addByPrefix('purplehold', 'purple hold piece');
|
|
|
|
animation.addByPrefix('greenhold', 'green hold piece');
|
|
|
|
animation.addByPrefix('redhold', 'red hold piece');
|
|
|
|
animation.addByPrefix('bluehold', 'blue hold piece');
|
|
|
|
|
|
|
|
setGraphicSize(Std.int(width * 0.7));
|
|
|
|
updateHitbox();
|
|
|
|
antialiasing = true;
|
2021-03-20 08:33:44 +00:00
|
|
|
|
|
|
|
// colorSwap.colorToReplace = 0xFFF9393F;
|
|
|
|
// colorSwap.newColor = 0xFF00FF00;
|
|
|
|
|
|
|
|
// color = FlxG.random.color();
|
|
|
|
// color.saturation *= 4;
|
|
|
|
// replaceColor(0xFFC1C1C1, FlxColor.RED);
|
2021-01-25 09:18:44 +00:00
|
|
|
}
|
2020-10-03 06:50:15 +00:00
|
|
|
|
2021-03-21 18:45:46 +00:00
|
|
|
colorSwap = new ColorSwap();
|
|
|
|
shader = colorSwap.shader;
|
2021-03-21 20:29:47 +00:00
|
|
|
updateColors();
|
2021-03-21 18:45:46 +00:00
|
|
|
|
2020-10-13 09:36:45 +00:00
|
|
|
switch (noteData)
|
2020-10-03 06:50:15 +00:00
|
|
|
{
|
2020-10-13 09:36:45 +00:00
|
|
|
case 0:
|
|
|
|
x += swagWidth * 0;
|
|
|
|
animation.play('purpleScroll');
|
2020-10-03 06:50:15 +00:00
|
|
|
case 1:
|
2020-10-13 09:36:45 +00:00
|
|
|
x += swagWidth * 1;
|
|
|
|
animation.play('blueScroll');
|
|
|
|
case 2:
|
2020-10-03 17:36:39 +00:00
|
|
|
x += swagWidth * 2;
|
2020-10-04 08:38:21 +00:00
|
|
|
animation.play('greenScroll');
|
2020-10-13 09:36:45 +00:00
|
|
|
case 3:
|
2020-10-03 17:36:39 +00:00
|
|
|
x += swagWidth * 3;
|
2020-10-04 08:38:21 +00:00
|
|
|
animation.play('redScroll');
|
2020-10-03 06:50:15 +00:00
|
|
|
}
|
|
|
|
|
2020-10-24 09:36:50 +00:00
|
|
|
// trace(prevNote);
|
2020-10-05 05:13:12 +00:00
|
|
|
|
2020-10-20 01:59:00 +00:00
|
|
|
if (isSustainNote && prevNote != null)
|
2020-10-03 19:32:15 +00:00
|
|
|
{
|
2020-10-03 06:50:15 +00:00
|
|
|
alpha = 0.6;
|
2020-10-05 05:13:12 +00:00
|
|
|
|
2021-03-30 22:10:15 +00:00
|
|
|
if (PreferencesMenu.getPref('downscroll'))
|
|
|
|
angle = 180;
|
|
|
|
|
2020-10-05 05:13:12 +00:00
|
|
|
x += width / 2;
|
|
|
|
|
|
|
|
switch (noteData)
|
|
|
|
{
|
2020-10-20 01:59:00 +00:00
|
|
|
case 2:
|
2020-10-05 05:13:12 +00:00
|
|
|
animation.play('greenholdend');
|
2020-10-20 01:59:00 +00:00
|
|
|
case 3:
|
2020-10-05 05:13:12 +00:00
|
|
|
animation.play('redholdend');
|
2020-10-20 01:59:00 +00:00
|
|
|
case 1:
|
2020-10-05 05:13:12 +00:00
|
|
|
animation.play('blueholdend');
|
2020-10-20 01:59:00 +00:00
|
|
|
case 0:
|
2020-10-05 05:13:12 +00:00
|
|
|
animation.play('purpleholdend');
|
|
|
|
}
|
|
|
|
|
|
|
|
updateHitbox();
|
|
|
|
|
|
|
|
x -= width / 2;
|
|
|
|
|
2021-02-02 05:48:22 +00:00
|
|
|
if (PlayState.curStage.startsWith('school'))
|
2021-02-01 10:52:10 +00:00
|
|
|
x += 30;
|
|
|
|
|
2020-10-20 01:59:00 +00:00
|
|
|
if (prevNote.isSustainNote)
|
2020-10-05 05:13:12 +00:00
|
|
|
{
|
|
|
|
switch (prevNote.noteData)
|
|
|
|
{
|
2021-02-13 22:39:31 +00:00
|
|
|
case 0:
|
|
|
|
prevNote.animation.play('purplehold');
|
|
|
|
case 1:
|
|
|
|
prevNote.animation.play('bluehold');
|
2020-10-20 01:59:00 +00:00
|
|
|
case 2:
|
2020-10-05 05:13:12 +00:00
|
|
|
prevNote.animation.play('greenhold');
|
2020-10-20 01:59:00 +00:00
|
|
|
case 3:
|
2020-10-05 05:13:12 +00:00
|
|
|
prevNote.animation.play('redhold');
|
|
|
|
}
|
|
|
|
|
2021-02-13 22:39:31 +00:00
|
|
|
prevNote.updateHitbox();
|
2021-08-02 01:29:34 +00:00
|
|
|
|
2021-12-06 22:49:05 +00:00
|
|
|
var scaleThing:Float = Math.round((Conductor.stepCrochet) * (0.45 * FlxMath.roundDecimal(SongLoad.getSpeed(), 2)));
|
2021-08-02 01:29:34 +00:00
|
|
|
// get them a LIL closer together cuz the antialiasing blurs the edges
|
|
|
|
if (antialiasing)
|
|
|
|
scaleThing *= 1.0 + (1.0 / prevNote.frameHeight);
|
|
|
|
prevNote.scale.y = scaleThing / prevNote.frameHeight;
|
|
|
|
prevNote.updateHitbox();
|
2020-10-05 05:13:12 +00:00
|
|
|
}
|
2020-10-03 19:32:15 +00:00
|
|
|
}
|
2020-10-03 06:50:15 +00:00
|
|
|
}
|
2020-10-03 17:36:39 +00:00
|
|
|
|
2021-06-08 01:14:50 +00:00
|
|
|
override function destroy()
|
|
|
|
{
|
|
|
|
prevNote = null;
|
|
|
|
|
|
|
|
super.destroy();
|
|
|
|
}
|
|
|
|
|
2021-03-21 18:45:46 +00:00
|
|
|
public function updateColors():Void
|
|
|
|
{
|
|
|
|
colorSwap.update(arrowColors[noteData]);
|
|
|
|
}
|
|
|
|
|
2020-10-03 17:36:39 +00:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
|
|
|
|
|
|
|
if (mustPress)
|
|
|
|
{
|
2021-04-08 01:29:32 +00:00
|
|
|
// miss on the NEXT frame so lag doesnt make u miss notes
|
2021-04-08 11:33:36 +00:00
|
|
|
if (willMiss && !wasGoodHit)
|
2021-04-08 01:29:32 +00:00
|
|
|
{
|
2020-10-03 17:36:39 +00:00
|
|
|
tooLate = true;
|
2021-04-08 01:29:32 +00:00
|
|
|
canBeHit = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-22 21:53:38 +00:00
|
|
|
if (!pastHalfWay && data.strumTime <= Conductor.songPosition)
|
2021-12-30 05:09:16 +00:00
|
|
|
{
|
|
|
|
pastHalfWay = true;
|
|
|
|
noteSpeedMulti *= 2;
|
|
|
|
}
|
|
|
|
|
2022-01-22 21:53:38 +00:00
|
|
|
if (data.strumTime > Conductor.songPosition - HIT_WINDOW)
|
2021-12-05 23:51:31 +00:00
|
|
|
{ // * 0.5 if sustain note, so u have to keep holding it closer to all the way thru!
|
2022-01-22 21:53:38 +00:00
|
|
|
if (data.strumTime < Conductor.songPosition + (HIT_WINDOW * (isSustainNote ? 0.5 : 1)))
|
2021-04-08 01:29:32 +00:00
|
|
|
canBeHit = true;
|
|
|
|
}
|
2021-04-10 22:23:56 +00:00
|
|
|
else
|
2021-04-08 01:29:32 +00:00
|
|
|
{
|
|
|
|
canBeHit = true;
|
|
|
|
willMiss = true;
|
|
|
|
}
|
|
|
|
}
|
2020-10-03 17:36:39 +00:00
|
|
|
}
|
|
|
|
else
|
2020-10-04 06:42:58 +00:00
|
|
|
{
|
2020-10-03 17:36:39 +00:00
|
|
|
canBeHit = false;
|
|
|
|
|
2022-01-22 21:53:38 +00:00
|
|
|
if (data.strumTime <= Conductor.songPosition)
|
2020-10-04 06:42:58 +00:00
|
|
|
wasGoodHit = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tooLate)
|
|
|
|
{
|
|
|
|
if (alpha > 0.3)
|
|
|
|
alpha = 0.3;
|
|
|
|
}
|
2020-10-03 17:36:39 +00:00
|
|
|
}
|
2020-10-03 06:50:15 +00:00
|
|
|
}
|
2022-01-22 21:53:38 +00:00
|
|
|
|
|
|
|
typedef NoteData =
|
|
|
|
{
|
|
|
|
var strumTime:Float;
|
|
|
|
var noteData:Int;
|
|
|
|
var sustainLength:Float;
|
|
|
|
var altNote:Bool;
|
|
|
|
}
|