note angle finally fucking works
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
1745
|
||||
1758
|
||||
+21
-32
@@ -66,6 +66,7 @@ class Note extends FlxSprite
|
||||
public var noteType(get, null):String;
|
||||
|
||||
@:dox(hide) public var __strumCameras:Array<FlxCamera> = null;
|
||||
@:dox(hide) public var __strum:Strum = null;
|
||||
@:dox(hide) public var __noteAngle:Float = 0;
|
||||
|
||||
private function get_noteType() {
|
||||
@@ -159,6 +160,12 @@ class Note extends FlxSprite
|
||||
public var lastScrollSpeed:Null<Float> = null;
|
||||
public var angleOffsets:Bool = true;
|
||||
|
||||
/**
|
||||
* Whenever the position of the note should be relative to the strum position or not.
|
||||
* For example, if this is true, a note at the position 0; 0 will be on the strum, instead of at the top left of the screen.
|
||||
*/
|
||||
public var strumRelativePos:Bool = true;
|
||||
|
||||
override function draw() {
|
||||
@:privateAccess var oldDefaultCameras = FlxCamera._defaultCameras;
|
||||
@:privateAccess if (__strumCameras != null) FlxCamera._defaultCameras = __strumCameras;
|
||||
@@ -168,47 +175,29 @@ class Note extends FlxSprite
|
||||
rotOffset.y += 2;
|
||||
if (negativeScroll) offset.y *= -1;
|
||||
|
||||
if (angleOffsets && Std.int(__noteAngle % 360) != 0) {
|
||||
// get default values
|
||||
var oldOffset = FlxPoint.get(offset.x, offset.y);
|
||||
var oldOrigin = FlxPoint.get(origin.x, origin.y);
|
||||
if (__strum != null && strumRelativePos) {
|
||||
var pos = FlxPoint.get(x, y);
|
||||
|
||||
// get offset pos without origin
|
||||
var pos = FlxPoint.get(-offset.x, -offset.y);
|
||||
setPosition(__strum.x, __strum.y);
|
||||
|
||||
// updates sin and cos values for angle
|
||||
updateTrig();
|
||||
rotOffset.x -= pos.x / scale.x;
|
||||
rotOffset.y -= pos.y / scale.y;
|
||||
|
||||
var sin = _sinAngle;
|
||||
var cos = _cosAngle;
|
||||
|
||||
var anglePos = FlxPoint.get(
|
||||
(-cos * pos.x) + (-sin * pos.y),
|
||||
(-sin * pos.x) + (-cos * pos.y));
|
||||
this.rotOffsetAngle = __noteAngle;
|
||||
|
||||
// applies new values
|
||||
x -= anglePos.x;
|
||||
y -= anglePos.y;
|
||||
offset.set();
|
||||
origin.set(oldOrigin.x - oldOffset.x, oldOrigin.y - oldOffset.y);
|
||||
|
||||
// draw
|
||||
super.draw();
|
||||
|
||||
// reset values
|
||||
offset.set(oldOffset.x, oldOffset.y);
|
||||
origin.set(oldOrigin.x, oldOrigin.y);
|
||||
x += anglePos.x;
|
||||
y += anglePos.y;
|
||||
this.rotOffsetAngle = 0;
|
||||
|
||||
// put flxpoints back in the recycling pool
|
||||
oldOffset.put();
|
||||
oldOrigin.put();
|
||||
rotOffset.x += pos.x / scale.x;
|
||||
rotOffset.y += pos.y / scale.y;
|
||||
|
||||
setPosition(pos.x, pos.y);
|
||||
pos.put();
|
||||
anglePos.put();
|
||||
return;
|
||||
} else {
|
||||
super.draw();
|
||||
}
|
||||
super.draw();
|
||||
|
||||
if (negativeScroll) offset.y *= -1;
|
||||
if (antialiasing && nextSustain == null)
|
||||
rotOffset.y -= 2;
|
||||
|
||||
+31
-21
@@ -46,32 +46,42 @@ class Strum extends FlxSprite {
|
||||
public function updateNotePosition(daNote:Note) {
|
||||
if (!daNote.exists) return;
|
||||
|
||||
var offset = FlxPoint.get(daNote.isSustainNote ? ((Note.swagWidth - daNote.width) / 2) : 0, (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(getScrollSpeed(daNote), 2)));
|
||||
var realOffset = FlxPoint.get(0, 0);
|
||||
|
||||
|
||||
daNote.__strumCameras = lastDrawCameras;
|
||||
|
||||
if (daNote.isSustainNote) offset.y -= Note.swagWidth / 2;
|
||||
|
||||
daNote.__strum = this;
|
||||
daNote.scrollFactor.set(scrollFactor.x, scrollFactor.y);
|
||||
|
||||
var noteAngle = daNote.__noteAngle = getNotesAngle(daNote);
|
||||
daNote.angle = daNote.isSustainNote ? noteAngle : angle;
|
||||
if (Std.int(noteAngle % 360) != 0) {
|
||||
var noteAngleCos = Math.cos(noteAngle / 180 * Math.PI);
|
||||
var noteAngleSin = Math.sin(noteAngle / 180 * Math.PI);
|
||||
realOffset.x = (noteAngleCos * offset.x) + (noteAngleSin * offset.y);
|
||||
realOffset.y = (noteAngleSin * offset.x) + (noteAngleCos * offset.y);
|
||||
} else {
|
||||
realOffset.x = offset.x;
|
||||
realOffset.y = offset.y;
|
||||
}
|
||||
realOffset.y *= -1;
|
||||
|
||||
daNote.setPosition(x + realOffset.x, y + realOffset.y);
|
||||
|
||||
offset.put();
|
||||
realOffset.put();
|
||||
if (daNote.strumRelativePos) {
|
||||
daNote.setPosition(daNote.isSustainNote ? ((Note.swagWidth - daNote.width) / 2) : 0, (daNote.strumTime - Conductor.songPosition) * (0.45 * FlxMath.roundDecimal(getScrollSpeed(daNote), 2)));
|
||||
if (daNote.isSustainNote) daNote.y += Note.swagWidth / 2;
|
||||
} else {
|
||||
var offset = FlxPoint.get(0, (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(getScrollSpeed(daNote), 2)));
|
||||
var realOffset = FlxPoint.get(0, 0);
|
||||
|
||||
if (daNote.isSustainNote) offset.y -= Note.swagWidth / 2;
|
||||
|
||||
if (Std.int(noteAngle % 360) != 0) {
|
||||
var noteAngleCos = Math.cos(noteAngle / 180 * Math.PI);
|
||||
var noteAngleSin = Math.sin(noteAngle / 180 * Math.PI);
|
||||
var aOffset:FlxPoint = FlxPoint.get(
|
||||
(daNote.origin.x / daNote.scale.x) - daNote.offset.x,
|
||||
(daNote.origin.y / daNote.scale.y) - daNote.offset.y
|
||||
);
|
||||
realOffset.x = -aOffset.x + (noteAngleCos * (offset.x + aOffset.x)) + (noteAngleSin * (offset.y + aOffset.y));
|
||||
realOffset.y = -aOffset.y + (noteAngleSin * (offset.x + aOffset.x)) + (noteAngleCos * (offset.y + aOffset.y));
|
||||
} else {
|
||||
realOffset.x = offset.x;
|
||||
realOffset.y = offset.y;
|
||||
}
|
||||
realOffset.y *= -1;
|
||||
|
||||
daNote.setPosition(x + realOffset.x, y + realOffset.y);
|
||||
|
||||
offset.put();
|
||||
realOffset.put();
|
||||
}
|
||||
}
|
||||
|
||||
public function updateSustain(daNote:Note) {
|
||||
|
||||
Reference in New Issue
Block a user