Funkin/source/Note.hx

78 lines
1.3 KiB
Haxe
Raw Normal View History

2020-10-03 06:50:15 +00:00
package;
import flixel.FlxSprite;
import flixel.util.FlxColor;
class Note extends FlxSprite
{
public var strumTime:Float = 0;
public var mustPress:Bool = false;
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;
2020-10-03 06:50:15 +00:00
2020-10-03 19:32:15 +00:00
public var noteScore:Float = 1;
2020-10-03 06:50:15 +00:00
public function new(strumTime:Float, noteData:Int)
{
super();
2020-10-03 17:36:39 +00:00
x += 100;
2020-10-03 06:50:15 +00:00
this.strumTime = strumTime;
2020-10-03 17:36:39 +00:00
2020-10-03 06:50:15 +00:00
this.noteData = noteData;
makeGraphic(50, 50);
2020-10-03 17:36:39 +00:00
var swagWidth:Float = 55;
2020-10-03 06:50:15 +00:00
switch (Math.abs(noteData))
{
case 1:
2020-10-03 17:36:39 +00:00
x += swagWidth * 2;
2020-10-03 06:50:15 +00:00
color = FlxColor.GREEN;
case 2:
2020-10-03 17:36:39 +00:00
x += swagWidth * 3;
2020-10-03 06:50:15 +00:00
color = FlxColor.RED;
case 3:
2020-10-03 17:36:39 +00:00
x += swagWidth * 1;
2020-10-03 06:50:15 +00:00
color = FlxColor.BLUE;
case 4:
2020-10-03 17:36:39 +00:00
x += swagWidth * 0;
2020-10-03 06:50:15 +00:00
color = FlxColor.PURPLE;
}
if (noteData < 0)
2020-10-03 19:32:15 +00:00
{
noteScore * 0.2;
2020-10-03 06:50:15 +00:00
alpha = 0.6;
2020-10-03 19:32:15 +00:00
}
2020-10-03 06:50:15 +00:00
}
2020-10-03 17:36:39 +00:00
override function update(elapsed:Float)
{
super.update(elapsed);
if (mustPress)
{
if (strumTime > Conductor.songPosition - Conductor.safeZoneOffset
&& strumTime < Conductor.songPosition + Conductor.safeZoneOffset)
{
canBeHit = true;
}
else
canBeHit = false;
if (strumTime < Conductor.songPosition - Conductor.safeZoneOffset)
tooLate = true;
}
else
canBeHit = false;
if (tooLate && alpha > 0.3)
alpha *= 0.3;
}
2020-10-03 06:50:15 +00:00
}