preliminary hold note drawing

This commit is contained in:
msk
2023-09-17 01:24:53 -07:00
parent b61d01d1da
commit a63c0ec3dc
2 changed files with 37 additions and 1 deletions
+1 -1
View File
@@ -167,8 +167,8 @@ grow_horizontal = 2
grow_vertical = 2
[node name="HoldTest" type="Polygon2D" parent="ViewportView/2D Viewport/Viewport Control/Holds ViewportView/Holds Viewport/Holds Scroll"]
position = Vector2(0, -6000)
color = Color(1, 1, 1, 0.921569)
antialiased = true
polygon = PackedVector2Array(0, 0, 300, 0, 1100, -1920, 800, -1920)
[node name="Holds Filter" type="TextureRect" parent="ViewportView/2D Viewport/Viewport Control/Holds ViewportView/Holds Viewport"]
+36
View File
@@ -1,3 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection.PortableExecutable;
using Godot;
using WacK.Data.Chart;
@@ -72,6 +74,7 @@ namespace WacK.Scenes
{
case NotePlayType.HoldStart:
nNote = noteHold.Instantiate<THNoteHold>();
RealizeHolds(note as NoteHold);
break;
case NotePlayType.Touch:
nNote = noteTouch.Instantiate<THNotePlay>();
@@ -88,10 +91,43 @@ namespace WacK.Scenes
}
}
private void RealizeHolds(NoteHold note)
{
GD.Print($"Creating hold point that has {note.points.Count} segments");
List<Vector2> verts = new(note.points.Count*2 + 2);
// HoldStart's pos
verts.Add(new Vector2((float)note.position * 1920/60, (float)note.time * -PIXELS_PER_SECOND));
// ascending -- "left" side
foreach (var (t, n) in note.points)
{
GD.Print($"{t}: {n.position}+{n.size}");
verts.Add(new Vector2((float)n.position * 1920/60, t * -PIXELS_PER_SECOND));
GD.Print($"{verts.Count} verts recorded");
}
// descending
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));
}
// HoldStart's end
verts.Add(new Vector2((float)((int)note.position + (int)note.size) * 1920/60, (float)note.time * -PIXELS_PER_SECOND));
GD.Print($"Created {verts.Count} verts");
var p2d = new Polygon2D
{
Polygon = verts.ToArray(),
Antialiased = true
};
GD.Print($"Created Polygon with {p2d.Polygon.Count()} verts");
scrollDisplay.AddChild(p2d);
}
public override void _Process(double delta)
{
var nPos = noteDisplay.Position;
nPos.Y += (float)delta * PIXELS_PER_SECOND;
// nPos.Y = 142375.875f; // Bad Apple Expert: OOB hold note
noteDisplay.Position = nPos;
scrollDisplay.Position = nPos;
}