From fa0c53ac3ee95e3fd5a2c4246bcce1bb85288a63 Mon Sep 17 00:00:00 2001 From: Turtike Date: Wed, 4 Feb 2026 00:03:12 +0800 Subject: [PATCH] Implement note visuals update method. --- rhythm_game/note/visual/hold/hold_note.gd | 25 ++++++++++++++++++++- rhythm_game/note/visual/hold/hold_note.tscn | 4 +++- rhythm_game/note/visual/note_visual.gd | 3 +++ rhythm_game/note/visual/tap/tap_note.gd | 8 ++++--- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/rhythm_game/note/visual/hold/hold_note.gd b/rhythm_game/note/visual/hold/hold_note.gd index 8507f3c..f942815 100644 --- a/rhythm_game/note/visual/hold/hold_note.gd +++ b/rhythm_game/note/visual/hold/hold_note.gd @@ -6,13 +6,36 @@ class_name HoldNote extends NoteVisual var start_id: int var end_id: int +var start_beat: float +var end_beat: float func reset() -> void: start_id = -1 end_id = -1 + start_beat = -999.0 + end_beat = -999.0 func in_use() -> bool: return start_id >= 0 or end_id >= 0 func update(beat: float) -> void: - pass + var start_scroll: float + if start_beat: + start_scroll = _calculate_scroll(start_beat, beat) + else: + start_scroll = 999.0 # Decently up. (TODO Replace with offset_begin). + _set_start_scroll(start_scroll) + + var end_scroll: float + if end_beat: + end_scroll = _calculate_scroll(end_beat, beat) + else: + end_scroll = -999.0 # Decently down. (TODO Replace with offset_end). + _set_end_scroll(end_scroll) + +# ======== IMPLEMENTATION ======== # +func _set_start_scroll(scroll: float) -> void: + start.y = scroll + +func _set_end_scroll(scroll: float) -> void: + end.y = scroll diff --git a/rhythm_game/note/visual/hold/hold_note.tscn b/rhythm_game/note/visual/hold/hold_note.tscn index fde0364..49a3c3b 100644 --- a/rhythm_game/note/visual/hold/hold_note.tscn +++ b/rhythm_game/note/visual/hold/hold_note.tscn @@ -2,8 +2,10 @@ [ext_resource type="Script" uid="uid://cbsnb8bdby0d" path="res://rhythm_game/note/visual/hold/hold_note.gd" id="1_5cv34"] -[node name="HoldNote" type="Node2D" unique_id=320259211] +[node name="HoldNote" type="Node2D" unique_id=320259211 node_paths=PackedStringArray("start", "end")] script = ExtResource("1_5cv34") +start = NodePath("NoteStart") +end = NodePath("NoteEnd") metadata/_custom_type_script = "uid://cbsnb8bdby0d" [node name="NoteStart" type="Node2D" parent="." unique_id=1911676927] diff --git a/rhythm_game/note/visual/note_visual.gd b/rhythm_game/note/visual/note_visual.gd index 5080e91..dc2377c 100644 --- a/rhythm_game/note/visual/note_visual.gd +++ b/rhythm_game/note/visual/note_visual.gd @@ -20,3 +20,6 @@ func _notification(what: int) -> void: _lane = get_parent() as Lane NOTIFICATION_UNPARENTED: _lane = null + +static func _calculate_scroll(target_beat: float, current_beat: float) -> float: + return Settings.get_note_scroll_speed() * (current_beat - target_beat) diff --git a/rhythm_game/note/visual/tap/tap_note.gd b/rhythm_game/note/visual/tap/tap_note.gd index 2f3ef54..7fbef81 100644 --- a/rhythm_game/note/visual/tap/tap_note.gd +++ b/rhythm_game/note/visual/tap/tap_note.gd @@ -1,14 +1,16 @@ class_name TapNote extends NoteVisual +var hit_beat: float = -999.0 + var id: int = -1 -#TODO: Add all the members needed so a note can be updated. - func reset() -> void: id = -1 + hit_beat = -999.0 + position = Vector2(0, 9999.0) func in_use() -> bool: return id >= 0 func update(beat: float) -> void: - pass + position.y = _calculate_scroll(hit_beat, beat)