rework hold notes' "long things" to properly draw out of bounds
This commit is contained in:
+2
-2
@@ -59,7 +59,7 @@ uv1_scale = Vector3(-1, 1, 1)
|
|||||||
[sub_resource type="ViewportTexture" id="ViewportTexture_w20vk"]
|
[sub_resource type="ViewportTexture" id="ViewportTexture_w20vk"]
|
||||||
viewport_path = NodePath("Mask")
|
viewport_path = NodePath("Mask")
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_80tx5"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_2lmy2"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
shader = ExtResource("3_rjbyl")
|
shader = ExtResource("3_rjbyl")
|
||||||
shader_parameter/mask = SubResource("ViewportTexture_w20vk")
|
shader_parameter/mask = SubResource("ViewportTexture_w20vk")
|
||||||
@@ -146,7 +146,7 @@ anchor_mode = 0
|
|||||||
editor_draw_screen = false
|
editor_draw_screen = false
|
||||||
|
|
||||||
[node name="Background" parent="ViewportView/2D Viewport/Viewport Control" instance=ExtResource("2_8g6gv")]
|
[node name="Background" parent="ViewportView/2D Viewport/Viewport Control" instance=ExtResource("2_8g6gv")]
|
||||||
material = SubResource("ShaderMaterial_80tx5")
|
material = SubResource("ShaderMaterial_2lmy2")
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
offset_top = -1920.0
|
offset_top = -1920.0
|
||||||
offset_right = 1920.0
|
offset_right = 1920.0
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace WacK.Data.Chart
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The note's radial position out of 60.
|
/// The note's radial position out of 60.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? position;
|
public int? pos;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The radial size of the note.
|
/// The radial size of the note.
|
||||||
@@ -32,7 +32,7 @@ namespace WacK.Data.Chart
|
|||||||
{
|
{
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.measureBeat = measureBeat;
|
this.measureBeat = measureBeat;
|
||||||
this.position = position;
|
this.pos = position;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+31
-31
@@ -48,8 +48,9 @@ namespace WacK.Scenes
|
|||||||
|
|
||||||
private Chart chart;
|
private Chart chart;
|
||||||
|
|
||||||
// scroll speed
|
// base scroll speed, which we can apply multipliers on
|
||||||
private const float PIXELS_PER_SECOND = 2000;
|
public static readonly float BASE_PIXELS_PER_SECOND = 800;
|
||||||
|
public static float scrollPxPerSec = BASE_PIXELS_PER_SECOND * 3.5f;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
@@ -76,7 +77,7 @@ namespace WacK.Scenes
|
|||||||
{
|
{
|
||||||
case NotePlayType.HoldStart:
|
case NotePlayType.HoldStart:
|
||||||
nNote = noteHold.Instantiate<THNoteHold>();
|
nNote = noteHold.Instantiate<THNoteHold>();
|
||||||
RealizeHolds(note as NoteHold);
|
((THNoteHold)nNote).InitHold((NoteHold)note, scrollDisplay);
|
||||||
break;
|
break;
|
||||||
case NotePlayType.Touch:
|
case NotePlayType.Touch:
|
||||||
nNote = noteTouch.Instantiate<THNotePlay>();
|
nNote = noteTouch.Instantiate<THNotePlay>();
|
||||||
@@ -86,46 +87,45 @@ namespace WacK.Scenes
|
|||||||
}
|
}
|
||||||
nNote.Init(note);
|
nNote.Init(note);
|
||||||
var nPos = nNote.Position;
|
var nPos = nNote.Position;
|
||||||
nPos.Y = msNote.Key * -PIXELS_PER_SECOND;
|
nPos.Y = msNote.Key * -scrollPxPerSec;
|
||||||
nNote.Position = nPos;
|
nNote.Position = nPos;
|
||||||
noteDisplay.AddChild(nNote);
|
noteDisplay.AddChild(nNote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RealizeHolds(NoteHold note)
|
// private void RealizeHolds(NoteHold note)
|
||||||
{
|
// {
|
||||||
List<Vector2> verts = new(note.points.Count*2 + 2);
|
// List<Vector2> verts = new(note.points.Count*2 + 2);
|
||||||
|
|
||||||
// HoldStart's pos
|
// // HoldStart's pos
|
||||||
verts.Add(new Vector2((float)note.position * 1920/60, (float)note.time * -PIXELS_PER_SECOND));
|
// verts.Add(new Vector2((float)note.pos * 1920/60, (float)note.time * -scrollPxPerSec));
|
||||||
// ascending -- "left" side
|
// // ascending -- "left" side
|
||||||
foreach (var (t, n) in note.points)
|
// foreach (var (t, n) in note.points)
|
||||||
{
|
// {
|
||||||
verts.Add(new Vector2((float)n.position * 1920/60, t * -PIXELS_PER_SECOND));
|
// verts.Add(new Vector2((float)n.pos * 1920/60, t * -scrollPxPerSec));
|
||||||
}
|
// }
|
||||||
// descending -- "right" side
|
// // descending -- "right" side
|
||||||
foreach (var (t, n) in note.points.Reverse())
|
// foreach (var (t, n) in note.points.Reverse())
|
||||||
{
|
// {
|
||||||
verts.Add(new Vector2((float)((int)n.position + (int)n.size) * 1920/60, t * -PIXELS_PER_SECOND));
|
// verts.Add(new Vector2((float)((int)n.pos + (int)n.size) * 1920/60, t * -scrollPxPerSec));
|
||||||
}
|
// }
|
||||||
// HoldStart's pos + size
|
// // HoldStart's pos + size
|
||||||
verts.Add(new Vector2((float)((int)note.position + (int)note.size) * 1920/60, (float)note.time * -PIXELS_PER_SECOND));
|
// verts.Add(new Vector2((float)((int)note.pos + (int)note.size) * 1920/60, (float)note.time * -scrollPxPerSec));
|
||||||
|
|
||||||
var p2d = new Polygon2D
|
// var p2d = new Polygon2D
|
||||||
{
|
// {
|
||||||
Polygon = verts.ToArray(),
|
// Polygon = verts.ToArray(),
|
||||||
Antialiased = true,
|
// Antialiased = true,
|
||||||
Modulate = new Color("#FFFFFFD0")
|
// Modulate = new Color("#FFFFFFD0")
|
||||||
};
|
// };
|
||||||
scrollDisplay.AddChild(p2d);
|
// scrollDisplay.AddChild(p2d);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
var nPos = noteDisplay.Position;
|
var nPos = noteDisplay.Position;
|
||||||
nPos.Y += (float)delta * PIXELS_PER_SECOND;
|
nPos.Y += (float)delta * scrollPxPerSec;
|
||||||
// nPos.Y = 142375.875f; // Bad Apple Expert: OOB hold note
|
|
||||||
noteDisplay.Position = nPos;
|
noteDisplay.Position = nPos;
|
||||||
scrollDisplay.Position = nPos;
|
scrollDisplay.Position = nPos;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,108 @@
|
|||||||
|
using System.Linq;
|
||||||
using Godot;
|
using Godot;
|
||||||
using WacK.Data.Chart;
|
using WacK.Data.Chart;
|
||||||
|
using WacK.Scenes;
|
||||||
|
|
||||||
namespace WacK.Things.TunnelObjects
|
namespace WacK.Things.TunnelObjects
|
||||||
{
|
{
|
||||||
public partial class THNoteHold : THNotePlay
|
public partial class THNoteHold : THNotePlay
|
||||||
{
|
{
|
||||||
public new NoteHold noteData;
|
public NoteHold holdNoteData;
|
||||||
|
private Node2D longThing;
|
||||||
|
|
||||||
public void Init(NoteHold noteData)
|
public void InitHold(NoteHold noteData, Control holdScroll)
|
||||||
{
|
{
|
||||||
base.Init(noteData);
|
holdNoteData = noteData;
|
||||||
this.noteData = noteData;
|
BuildLongThing(holdScroll);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: setup other Nodes to render hold note properly
|
// Create longThing in segments.
|
||||||
|
public void BuildLongThing(Control holdScroll)
|
||||||
|
{
|
||||||
|
longThing = new Node2D();
|
||||||
|
holdScroll.AddChild(longThing);
|
||||||
|
longThing.Position = new Vector2(0, (float)-holdNoteData.time * Play.scrollPxPerSec);
|
||||||
|
|
||||||
|
GD.Print($"{holdNoteData.points.Count}");
|
||||||
|
if (holdNoteData.points.Count > 0)
|
||||||
|
{
|
||||||
|
NotePlay lastHold = holdNoteData;
|
||||||
|
float segmentPos = 0;
|
||||||
|
foreach (var (_, curNote) in holdNoteData.points)
|
||||||
|
{
|
||||||
|
var curLength = Play.scrollPxPerSec * (float)(curNote.time - lastHold.time);
|
||||||
|
var segment = CreateSegment(lastHold, curNote);
|
||||||
|
longThing.AddChild(segment);
|
||||||
|
segment.Position = new Vector2(0, segmentPos);
|
||||||
|
|
||||||
|
segmentPos -= curLength;
|
||||||
|
lastHold = curNote;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GD.PrintErr("Tried to create a long note with no segments!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Polygon2D CreateSegment(NotePlay origin, NotePlay destination)
|
||||||
|
{
|
||||||
|
Vector2I textureSize = new(1920, 1920);
|
||||||
|
float minuteSize = textureSize.X / 60;
|
||||||
|
|
||||||
|
var length = Play.scrollPxPerSec * (float)(destination.time - origin.time);
|
||||||
|
var verts = new Vector2[4];
|
||||||
|
|
||||||
|
int originPos;
|
||||||
|
int originSize;
|
||||||
|
int destPos;
|
||||||
|
int destSize;
|
||||||
|
if (3 <= origin.size && origin.size <= 59)
|
||||||
|
{
|
||||||
|
originPos = ((int)origin.pos + 1)%60;
|
||||||
|
originSize = (int)origin.size - 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
originPos = (int)origin.pos;
|
||||||
|
originSize = (int)origin.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (3 <= destination.size && destination.size <= 59)
|
||||||
|
{
|
||||||
|
destPos = ((int)destination.pos + 1)%60;
|
||||||
|
destSize = (int)destination.size - 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
destPos = (int)destination.pos;
|
||||||
|
destSize = (int)destination.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
destPos = (int)Util.NearestMinute(originPos, destPos);
|
||||||
|
verts[0] = new Vector2(originPos * minuteSize, 0);
|
||||||
|
verts[1] = new Vector2(verts[0].X + originSize * minuteSize, 0);
|
||||||
|
verts[2] = new Vector2(minuteSize * (destPos + destSize), -length);
|
||||||
|
verts[3] = new Vector2(minuteSize * destPos, -length);
|
||||||
|
var segment = new Polygon2D() { Polygon = verts, Antialiased = true };
|
||||||
|
|
||||||
|
// draw overflow
|
||||||
|
var originFinalPos = originPos + originSize;
|
||||||
|
var destinationFinalPos = destPos + destSize;
|
||||||
|
if (originFinalPos > 60 || destinationFinalPos > 60)
|
||||||
|
{
|
||||||
|
var subSegment = new Polygon2D() { Polygon = verts, Antialiased = true };
|
||||||
|
subSegment.Translate(new Vector2(-60 * minuteSize, 0));
|
||||||
|
segment.AddChild(subSegment);
|
||||||
|
}
|
||||||
|
if (originFinalPos < 60 || destinationFinalPos < 60)
|
||||||
|
{
|
||||||
|
var subSegment = new Polygon2D() { Polygon = verts, Antialiased = true };
|
||||||
|
subSegment.Translate(new Vector2(60 * minuteSize, 0));
|
||||||
|
segment.AddChild(subSegment);
|
||||||
|
}
|
||||||
|
|
||||||
|
return segment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,12 +10,17 @@ namespace WacK.Things.TunnelObjects
|
|||||||
public void Init(NotePlay noteData)
|
public void Init(NotePlay noteData)
|
||||||
{
|
{
|
||||||
this.noteData = noteData;
|
this.noteData = noteData;
|
||||||
SetSizePos((int)noteData.position, (int)noteData.size);
|
SetSizePos((int)noteData.pos, (int)noteData.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSizePos(int pos, int size)
|
public void SetSizePos(int pos, int size)
|
||||||
{
|
{
|
||||||
// TODO: pos + size >= 60
|
if (3 <= size && size <= 59)
|
||||||
|
{
|
||||||
|
pos += 1;
|
||||||
|
size -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
var nPos = Position;
|
var nPos = Position;
|
||||||
nPos.X = pos * (1920f/60) - 12;
|
nPos.X = pos * (1920f/60) - 12;
|
||||||
Position = nPos;
|
Position = nPos;
|
||||||
|
|||||||
@@ -126,19 +126,6 @@ namespace WacK
|
|||||||
return pos / PlaySettings.playSpeedMultiplier / Constants.SCROLL_MULT;
|
return pos / PlaySettings.playSpeedMultiplier / Constants.SCROLL_MULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: notes scale to scroll position instead of strikeline
|
|
||||||
// (where calibration offsets can be applied)
|
|
||||||
public static Vector3 NoteScale(float zPos, float zOrigin = 0)
|
|
||||||
{
|
|
||||||
var val = zPos - zOrigin;
|
|
||||||
if (val <= Constants.NOTE_DRAW_DISTANCE)
|
|
||||||
{
|
|
||||||
var ratio = Mathf.Clamp((Constants.NOTE_DRAW_DISTANCE - val) / Constants.NOTE_DRAW_DISTANCE, 0, 1);
|
|
||||||
return new Vector3(ratio, ratio, 1);
|
|
||||||
}
|
|
||||||
return Vector3.Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string DifficultyValueToString(float diffPoint)
|
public static string DifficultyValueToString(float diffPoint)
|
||||||
{
|
{
|
||||||
return Mathf.FloorToInt(diffPoint).ToString() + (diffPoint > Mathf.Floor(diffPoint) ? "+" : "");
|
return Mathf.FloorToInt(diffPoint).ToString() + (diffPoint > Mathf.Floor(diffPoint) ? "+" : "");
|
||||||
|
|||||||
Reference in New Issue
Block a user