diff --git a/Scenes/Play.tscn b/Scenes/Play.tscn index ccfb8aa..2385129 100644 --- a/Scenes/Play.tscn +++ b/Scenes/Play.tscn @@ -59,7 +59,7 @@ uv1_scale = Vector3(-1, 1, 1) [sub_resource type="ViewportTexture" id="ViewportTexture_w20vk"] viewport_path = NodePath("Mask") -[sub_resource type="ShaderMaterial" id="ShaderMaterial_80tx5"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_2lmy2"] resource_local_to_scene = true shader = ExtResource("3_rjbyl") shader_parameter/mask = SubResource("ViewportTexture_w20vk") @@ -146,7 +146,7 @@ anchor_mode = 0 editor_draw_screen = false [node name="Background" parent="ViewportView/2D Viewport/Viewport Control" instance=ExtResource("2_8g6gv")] -material = SubResource("ShaderMaterial_80tx5") +material = SubResource("ShaderMaterial_2lmy2") layout_mode = 1 offset_top = -1920.0 offset_right = 1920.0 diff --git a/Scripts/Data/Chart/Note.cs b/Scripts/Data/Chart/Note.cs index e4fd040..5f9e73a 100755 --- a/Scripts/Data/Chart/Note.cs +++ b/Scripts/Data/Chart/Note.cs @@ -20,7 +20,7 @@ namespace WacK.Data.Chart /// /// The note's radial position out of 60. /// - public int? position; + public int? pos; /// /// The radial size of the note. @@ -32,7 +32,7 @@ namespace WacK.Data.Chart { this.time = time; this.measureBeat = measureBeat; - this.position = position; + this.pos = position; this.size = size; } diff --git a/Scripts/Scenes/Play.cs b/Scripts/Scenes/Play.cs index 769fec6..5313091 100644 --- a/Scripts/Scenes/Play.cs +++ b/Scripts/Scenes/Play.cs @@ -48,8 +48,9 @@ namespace WacK.Scenes private Chart chart; - // scroll speed - private const float PIXELS_PER_SECOND = 2000; + // base scroll speed, which we can apply multipliers on + public static readonly float BASE_PIXELS_PER_SECOND = 800; + public static float scrollPxPerSec = BASE_PIXELS_PER_SECOND * 3.5f; public override void _Ready() { @@ -76,7 +77,7 @@ namespace WacK.Scenes { case NotePlayType.HoldStart: nNote = noteHold.Instantiate(); - RealizeHolds(note as NoteHold); + ((THNoteHold)nNote).InitHold((NoteHold)note, scrollDisplay); break; case NotePlayType.Touch: nNote = noteTouch.Instantiate(); @@ -86,46 +87,45 @@ namespace WacK.Scenes } nNote.Init(note); var nPos = nNote.Position; - nPos.Y = msNote.Key * -PIXELS_PER_SECOND; + nPos.Y = msNote.Key * -scrollPxPerSec; nNote.Position = nPos; noteDisplay.AddChild(nNote); } } } - private void RealizeHolds(NoteHold note) - { - List verts = new(note.points.Count*2 + 2); + // private void RealizeHolds(NoteHold note) + // { + // List 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) - { - verts.Add(new Vector2((float)n.position * 1920/60, t * -PIXELS_PER_SECOND)); - } - // descending -- "right" side - 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 pos + size - verts.Add(new Vector2((float)((int)note.position + (int)note.size) * 1920/60, (float)note.time * -PIXELS_PER_SECOND)); + // // HoldStart's pos + // verts.Add(new Vector2((float)note.pos * 1920/60, (float)note.time * -scrollPxPerSec)); + // // ascending -- "left" side + // foreach (var (t, n) in note.points) + // { + // verts.Add(new Vector2((float)n.pos * 1920/60, t * -scrollPxPerSec)); + // } + // // descending -- "right" side + // foreach (var (t, n) in note.points.Reverse()) + // { + // verts.Add(new Vector2((float)((int)n.pos + (int)n.size) * 1920/60, t * -scrollPxPerSec)); + // } + // // HoldStart's pos + size + // verts.Add(new Vector2((float)((int)note.pos + (int)note.size) * 1920/60, (float)note.time * -scrollPxPerSec)); - var p2d = new Polygon2D - { - Polygon = verts.ToArray(), - Antialiased = true, - Modulate = new Color("#FFFFFFD0") - }; - scrollDisplay.AddChild(p2d); - } + // var p2d = new Polygon2D + // { + // Polygon = verts.ToArray(), + // Antialiased = true, + // Modulate = new Color("#FFFFFFD0") + // }; + // 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 + nPos.Y += (float)delta * scrollPxPerSec; noteDisplay.Position = nPos; scrollDisplay.Position = nPos; } diff --git a/Scripts/Things/TunnelObjects/THNoteHold.cs b/Scripts/Things/TunnelObjects/THNoteHold.cs index ec928f4..273f841 100644 --- a/Scripts/Things/TunnelObjects/THNoteHold.cs +++ b/Scripts/Things/TunnelObjects/THNoteHold.cs @@ -1,18 +1,108 @@ +using System.Linq; using Godot; using WacK.Data.Chart; +using WacK.Scenes; namespace WacK.Things.TunnelObjects { 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); - this.noteData = noteData; - - // TODO: setup other Nodes to render hold note properly + holdNoteData = noteData; + BuildLongThing(holdScroll); } + + // 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; + } } } \ No newline at end of file diff --git a/Scripts/Things/TunnelObjects/THNotePlay.cs b/Scripts/Things/TunnelObjects/THNotePlay.cs index f9713ca..5acc262 100644 --- a/Scripts/Things/TunnelObjects/THNotePlay.cs +++ b/Scripts/Things/TunnelObjects/THNotePlay.cs @@ -10,12 +10,17 @@ namespace WacK.Things.TunnelObjects public void Init(NotePlay 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) { - // TODO: pos + size >= 60 + if (3 <= size && size <= 59) + { + pos += 1; + size -= 2; + } + var nPos = Position; nPos.X = pos * (1920f/60) - 12; Position = nPos; diff --git a/Scripts/Util.cs b/Scripts/Util.cs index 82162ed..24c902c 100644 --- a/Scripts/Util.cs +++ b/Scripts/Util.cs @@ -126,19 +126,6 @@ namespace WacK 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) { return Mathf.FloorToInt(diffPoint).ToString() + (diffPoint > Mathf.Floor(diffPoint) ? "+" : "");