This repository has been archived by the owner on Jan 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package funkin.objects.note; | ||
|
||
import funkin.graphics.SmartSprite; | ||
|
||
class BasicNote extends SmartSprite { | ||
public var strumTime:Float = 0.0; | ||
public var noteData:Int = 0; | ||
public var noteSpeed:Float = 1.0; | ||
public var targetStrum:NoteStrum; | ||
public var parentNote:Note; | ||
public var childNote:Sustain; | ||
|
||
public var isSustainNote(default, set):Bool = false; | ||
inline function set_isSustainNote(value:Bool) { | ||
renderMode = value ? REPEAT : QUAD; | ||
return isSustainNote = value; | ||
} | ||
|
||
private var curSkinData:SkinMapData; | ||
public var skin(default, set):String = "default"; | ||
inline function set_skin(?value:String) { | ||
skin = value ?? SkinUtil.curSkin; | ||
curSkinData = NoteUtil.getSkinSprites(skin, noteData); | ||
updateSprites(); | ||
return skin; | ||
} | ||
|
||
public function changeSkin(?value:String) { | ||
if (value != skin) | ||
skin = value; | ||
} | ||
|
||
public function updateSprites() { | ||
loadFromSprite(curSkinData.baseSprite); | ||
} | ||
|
||
public var approachAngle:Float = 0; | ||
public var spawnMult:Float = 1.0; | ||
|
||
public function new(noteData:Int = 0, strumTime:Float = 0.0, skin:String = "default") { | ||
super(); | ||
this.noteData = noteData; | ||
this.strumTime = strumTime; | ||
this.skin = skin; | ||
approachAngle = Preferences.getPref('downscroll') ? 180 : 0; | ||
} | ||
|
||
override function update(elapsed:Float) { | ||
super.update(elapsed); | ||
if (targetStrum != null) { | ||
moveToStrum(); | ||
} | ||
} | ||
|
||
inline public function moveToStrum() { | ||
final noteMove:Float = getMillPos(Conductor.songPosition - strumTime); // Position with strumtime | ||
y = targetStrum.y - (noteMove * getCos()); // Set Position | ||
x = targetStrum.x - (noteMove * -getSin()); | ||
} | ||
|
||
inline public function getCos() { | ||
return FlxMath.fastCos(FlxAngle.asRadians(approachAngle)); | ||
} | ||
|
||
inline public function getSin() { | ||
return FlxMath.fastSin(FlxAngle.asRadians(approachAngle)); | ||
} | ||
|
||
// Converts song milliseconds to a position on screen | ||
inline public function getMillPos(mills:Float):Float { | ||
return mills * (0.45 * noteSpeed); | ||
} | ||
|
||
// Converts a position on screen to song milliseconds | ||
inline public function getPosMill(pos:Float):Float { | ||
return pos / (0.45 * noteSpeed); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters