Compare commits
8 Commits
7bc4246375
...
56bc5d1ba5
| Author | SHA1 | Date | |
|---|---|---|---|
| 56bc5d1ba5 | |||
| 501ff6a7dc | |||
| dbf6a710a3 | |||
| 06a0424fd0 | |||
| 176465e067 | |||
| fa0c53ac3e | |||
| 6ac9be6c79 | |||
| 753a2b1030 |
@@ -6,4 +6,5 @@ func get_hit_pos() -> Vector2:
|
|||||||
|
|
||||||
## Should be connected to [signal NoteSpawner.notes_spawned].
|
## Should be connected to [signal NoteSpawner.notes_spawned].
|
||||||
func update(beat: float) -> void:
|
func update(beat: float) -> void:
|
||||||
pass
|
for note: NoteVisual in get_children():
|
||||||
|
note.update(beat)
|
||||||
|
|||||||
5
rhythm_game/note/editor/editor_note.gd
Normal file
5
rhythm_game/note/editor/editor_note.gd
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class_name EditorNote extends Node
|
||||||
|
|
||||||
|
@export var hit_beat: float = 0.0
|
||||||
|
@export var type: Note.TYPE = Note.TYPE.TAP
|
||||||
|
@export var lane: int = 0
|
||||||
1
rhythm_game/note/editor/editor_note.gd.uid
Normal file
1
rhythm_game/note/editor/editor_note.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cgif6nuped1v1
|
||||||
10
rhythm_game/note/editor/editor_note_array.gd
Normal file
10
rhythm_game/note/editor/editor_note_array.gd
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class_name EditorNoteArray extends NoteArray
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
for note: EditorNote in get_children():
|
||||||
|
if note == null:
|
||||||
|
return
|
||||||
|
# TODO: Make this insert sorted.
|
||||||
|
_beats.append(note.hit_beat)
|
||||||
|
_types.append(note.type)
|
||||||
|
_lanes.append(note.lane)
|
||||||
1
rhythm_game/note/editor/editor_note_array.gd.uid
Normal file
1
rhythm_game/note/editor/editor_note_array.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://b1x25i77v5nag
|
||||||
@@ -6,13 +6,36 @@ class_name HoldNote extends NoteVisual
|
|||||||
|
|
||||||
var start_id: int
|
var start_id: int
|
||||||
var end_id: int
|
var end_id: int
|
||||||
|
var start_beat: float
|
||||||
|
var end_beat: float
|
||||||
|
|
||||||
func reset() -> void:
|
func reset() -> void:
|
||||||
start_id = -1
|
start_id = -1
|
||||||
end_id = -1
|
end_id = -1
|
||||||
|
start_beat = -999.0
|
||||||
|
end_beat = -999.0
|
||||||
|
|
||||||
func in_use() -> bool:
|
func in_use() -> bool:
|
||||||
return start_id >= 0 or end_id >= 0
|
return start_id >= 0 or end_id >= 0
|
||||||
|
|
||||||
func update(beat: float) -> void:
|
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
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cbsnb8bdby0d" path="res://rhythm_game/note/visual/hold/hold_note.gd" id="1_5cv34"]
|
[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")
|
script = ExtResource("1_5cv34")
|
||||||
|
start = NodePath("NoteStart")
|
||||||
|
end = NodePath("NoteEnd")
|
||||||
metadata/_custom_type_script = "uid://cbsnb8bdby0d"
|
metadata/_custom_type_script = "uid://cbsnb8bdby0d"
|
||||||
|
|
||||||
[node name="NoteStart" type="Node2D" parent="." unique_id=1911676927]
|
[node name="NoteStart" type="Node2D" parent="." unique_id=1911676927]
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ func get_tap() -> TapNote:
|
|||||||
if tap == null:
|
if tap == null:
|
||||||
tap = _instantiate_tap()
|
tap = _instantiate_tap()
|
||||||
_used_taps[tap] = true
|
_used_taps[tap] = true
|
||||||
|
tap.reset()
|
||||||
return tap
|
return tap
|
||||||
|
|
||||||
## Return a tap note.
|
## Return a tap note.
|
||||||
@@ -50,6 +51,7 @@ func return_tap(tap: TapNote) -> void:
|
|||||||
"Returning tap note ", tap,
|
"Returning tap note ", tap,
|
||||||
" that was not spawned by pool ", self, "."
|
" that was not spawned by pool ", self, "."
|
||||||
)
|
)
|
||||||
|
tap.reset()
|
||||||
_free_taps.append(tap)
|
_free_taps.append(tap)
|
||||||
|
|
||||||
## Get a hold note. Instantiates one if no free nodes are available.
|
## Get a hold note. Instantiates one if no free nodes are available.
|
||||||
@@ -58,6 +60,7 @@ func get_hold() -> HoldNote:
|
|||||||
if hold == null:
|
if hold == null:
|
||||||
hold = _instantiate_hold()
|
hold = _instantiate_hold()
|
||||||
_used_holds[hold] = true
|
_used_holds[hold] = true
|
||||||
|
hold.reset()
|
||||||
return hold
|
return hold
|
||||||
|
|
||||||
## Return a hold note.
|
## Return a hold note.
|
||||||
@@ -71,6 +74,7 @@ func return_hold(hold: HoldNote) -> void:
|
|||||||
"Returning hold note ", hold,
|
"Returning hold note ", hold,
|
||||||
" that was not spawned by pool ", self, "."
|
" that was not spawned by pool ", self, "."
|
||||||
)
|
)
|
||||||
|
hold.reset()
|
||||||
_free_holds.append(hold)
|
_free_holds.append(hold)
|
||||||
|
|
||||||
## Spawn the given number of notes.
|
## Spawn the given number of notes.
|
||||||
@@ -89,8 +93,11 @@ var _used_taps: Dictionary[TapNote, bool]
|
|||||||
var _free_holds: Array[HoldNote]
|
var _free_holds: Array[HoldNote]
|
||||||
var _used_holds: Dictionary[HoldNote, bool]
|
var _used_holds: Dictionary[HoldNote, bool]
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
reserve(tap_size, hold_size)
|
||||||
|
|
||||||
func _instantiate_tap() -> TapNote:
|
func _instantiate_tap() -> TapNote:
|
||||||
return NoteScenes.get_tap(tap_skin).instantiate() as TapNote
|
return NoteScenes.get_tap(tap_skin).instantiate() as TapNote
|
||||||
|
|
||||||
func _instantiate_hold() -> HoldNote:
|
func _instantiate_hold() -> HoldNote:
|
||||||
return NoteScenes.get_tap(tap_skin).instantiate() as HoldNote
|
return NoteScenes.get_hold(tap_skin).instantiate() as HoldNote
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ static func get_hold(skin: StringName = "default") -> PackedScene:
|
|||||||
# ======== IMPLEMENTATION ======== #
|
# ======== IMPLEMENTATION ======== #
|
||||||
|
|
||||||
static var _tap_scenes: Dictionary[StringName, PackedScene] = {
|
static var _tap_scenes: Dictionary[StringName, PackedScene] = {
|
||||||
"default": load("uid://dq5ocf0272tet")
|
"default": load("uid://jbgxbhfpj806")
|
||||||
}
|
}
|
||||||
|
|
||||||
static var _hold_scenes: Dictionary[StringName, PackedScene] = {
|
static var _hold_scenes: Dictionary[StringName, PackedScene] = {
|
||||||
"default": load("uid://jbgxbhfpj806")
|
"default": load("uid://dq5ocf0272tet")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ func _set_visual_for_tap_at(note_id: int) -> void:
|
|||||||
var lane_id: int = notes.lane_at(note_id)
|
var lane_id: int = notes.lane_at(note_id)
|
||||||
var lane: Lane = lanes[lane_id]
|
var lane: Lane = lanes[lane_id]
|
||||||
var note: TapNote = pool.get_tap()
|
var note: TapNote = pool.get_tap()
|
||||||
|
note.id = note_id
|
||||||
|
note.hit_beat = notes.beat_at(note_id)
|
||||||
lane.add_child(note)
|
lane.add_child(note)
|
||||||
_note_visuals[note_id] = note
|
_note_visuals[note_id] = note
|
||||||
|
|
||||||
@@ -67,6 +69,8 @@ func _set_visual_for_hold_start_at(note_id: int) -> void:
|
|||||||
var lane_id: int = notes.lane_at(note_id)
|
var lane_id: int = notes.lane_at(note_id)
|
||||||
var lane: Lane = lanes[lane_id]
|
var lane: Lane = lanes[lane_id]
|
||||||
var note: HoldNote = pool.get_hold()
|
var note: HoldNote = pool.get_hold()
|
||||||
|
note.start_id = note_id
|
||||||
|
note.hit_beat = notes.beat_at(note_id)
|
||||||
lane.add_child(note)
|
lane.add_child(note)
|
||||||
_note_visuals[note_id] = note
|
_note_visuals[note_id] = note
|
||||||
_last_lane_holds[lane_id] = note
|
_last_lane_holds[lane_id] = note
|
||||||
@@ -82,10 +86,23 @@ func _set_visual_for_hold_end_at(note_id: int) -> void:
|
|||||||
_last_lane_holds[lane_id] = null
|
_last_lane_holds[lane_id] = null
|
||||||
|
|
||||||
func _remove_visual_for_tap_at(note_id: int) -> void:
|
func _remove_visual_for_tap_at(note_id: int) -> void:
|
||||||
pass
|
var note: TapNote = _note_visuals.get(note_id) as TapNote
|
||||||
|
if note == null:
|
||||||
|
return
|
||||||
|
pool.return_tap(note)
|
||||||
|
|
||||||
func _remove_visual_for_hold_start_at(note_id: int) -> void:
|
func _remove_visual_for_hold_start_at(note_id: int) -> void:
|
||||||
pass
|
var note: HoldNote = _note_visuals.get(note_id) as HoldNote
|
||||||
|
if note == null:
|
||||||
|
return
|
||||||
|
note.start_id = -1
|
||||||
|
if note.end_id < 0:
|
||||||
|
pool.return_hold(note)
|
||||||
|
|
||||||
func _remove_visual_for_hold_end_at(note_id: int) -> void:
|
func _remove_visual_for_hold_end_at(note_id: int) -> void:
|
||||||
pass
|
var note: HoldNote = _note_visuals.get(note_id) as HoldNote
|
||||||
|
if note == null:
|
||||||
|
return
|
||||||
|
note.end_id = -1
|
||||||
|
if note.start_id < 0:
|
||||||
|
pool.return_hold(note)
|
||||||
|
|||||||
@@ -20,3 +20,6 @@ func _notification(what: int) -> void:
|
|||||||
_lane = get_parent() as Lane
|
_lane = get_parent() as Lane
|
||||||
NOTIFICATION_UNPARENTED:
|
NOTIFICATION_UNPARENTED:
|
||||||
_lane = null
|
_lane = null
|
||||||
|
|
||||||
|
static func _calculate_scroll(target_beat: float, current_beat: float) -> float:
|
||||||
|
return Settings.get_note_scroll_speed() * (current_beat - target_beat)
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
class_name TapNote extends NoteVisual
|
class_name TapNote extends NoteVisual
|
||||||
|
|
||||||
|
var hit_beat: float = -999.0
|
||||||
|
|
||||||
var id: int = -1
|
var id: int = -1
|
||||||
|
|
||||||
#TODO: Add all the members needed so a note can be updated.
|
|
||||||
|
|
||||||
func reset() -> void:
|
func reset() -> void:
|
||||||
id = -1
|
id = -1
|
||||||
|
hit_beat = -999.0
|
||||||
|
position = Vector2(0, 9999.0)
|
||||||
|
|
||||||
func in_use() -> bool:
|
func in_use() -> bool:
|
||||||
return id >= 0
|
return id >= 0
|
||||||
|
|
||||||
func update(beat: float) -> void:
|
func update(beat: float) -> void:
|
||||||
pass
|
position.y = _calculate_scroll(hit_beat, beat)
|
||||||
|
|||||||
@@ -2,14 +2,17 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://102cl75cfpgw" path="res://rhythm_game/music_sync/event_layout.gd" id="1_jnfl3"]
|
[ext_resource type="Script" uid="uid://102cl75cfpgw" path="res://rhythm_game/music_sync/event_layout.gd" id="1_jnfl3"]
|
||||||
[ext_resource type="Script" uid="uid://s16dt0bu0jrg" path="res://rhythm_game/music_sync/conductor.gd" id="2_62aw1"]
|
[ext_resource type="Script" uid="uid://s16dt0bu0jrg" path="res://rhythm_game/music_sync/conductor.gd" id="2_62aw1"]
|
||||||
|
[ext_resource type="Script" uid="uid://dpu6645p40p43" path="res://rhythm_game/note/visual/note_spawner.gd" id="2_nuoj2"]
|
||||||
[ext_resource type="AudioStream" uid="uid://btmy8ffph5gn3" path="res://chart/test_nibelungen/audio.mp3" id="3_txi6k"]
|
[ext_resource type="AudioStream" uid="uid://btmy8ffph5gn3" path="res://chart/test_nibelungen/audio.mp3" id="3_txi6k"]
|
||||||
|
[ext_resource type="Script" uid="uid://u42y08gn6bi7" path="res://rhythm_game/lane/lane.gd" id="4_obbjr"]
|
||||||
[ext_resource type="Resource" uid="uid://b34uhnkvwfyc1" path="res://chart/test_nibelungen/tempo.tres" id="5_10cpq"]
|
[ext_resource type="Resource" uid="uid://b34uhnkvwfyc1" path="res://chart/test_nibelungen/tempo.tres" id="5_10cpq"]
|
||||||
[ext_resource type="Script" uid="uid://rg6orh6kutai" path="res://resource_type/music.gd" id="5_nsyv8"]
|
[ext_resource type="Script" uid="uid://rg6orh6kutai" path="res://resource_type/music.gd" id="5_nsyv8"]
|
||||||
|
[ext_resource type="Script" uid="uid://cgif6nuped1v1" path="res://rhythm_game/note/editor/editor_note.gd" id="5_wq11w"]
|
||||||
[ext_resource type="AudioStream" uid="uid://be8dyt7nfpffw" path="res://sfx/sfx_cowbell.ogg" id="6_ecbku"]
|
[ext_resource type="AudioStream" uid="uid://be8dyt7nfpffw" path="res://sfx/sfx_cowbell.ogg" id="6_ecbku"]
|
||||||
[ext_resource type="Script" uid="uid://bbpyym0kgujev" path="res://rhythm_game/metronome.gd" id="7_nsyv8"]
|
[ext_resource type="Script" uid="uid://bbpyym0kgujev" path="res://rhythm_game/metronome.gd" id="7_nsyv8"]
|
||||||
[ext_resource type="Script" uid="uid://8isyo4pxyj1r" path="res://rhythm_game/note/array/note_array.gd" id="9_10cpq"]
|
|
||||||
[ext_resource type="Script" uid="uid://c7h7ue6kjgoha" path="res://rhythm_game/note/view/note_view.gd" id="9_74aio"]
|
[ext_resource type="Script" uid="uid://c7h7ue6kjgoha" path="res://rhythm_game/note/view/note_view.gd" id="9_74aio"]
|
||||||
[ext_resource type="Script" uid="uid://clog51kfg2rsb" path="res://rhythm_game/note/visual/note_pool.gd" id="10_74aio"]
|
[ext_resource type="Script" uid="uid://clog51kfg2rsb" path="res://rhythm_game/note/visual/note_pool.gd" id="10_74aio"]
|
||||||
|
[ext_resource type="Script" uid="uid://b1x25i77v5nag" path="res://rhythm_game/note/editor/editor_note_array.gd" id="12_obbjr"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_10cpq"]
|
[sub_resource type="Resource" id="Resource_10cpq"]
|
||||||
script = ExtResource("5_nsyv8")
|
script = ExtResource("5_nsyv8")
|
||||||
@@ -21,6 +24,57 @@ metadata/_custom_type_script = "uid://rg6orh6kutai"
|
|||||||
[node name="RhythmGame" type="Node2D" unique_id=1479619523]
|
[node name="RhythmGame" type="Node2D" unique_id=1479619523]
|
||||||
script = ExtResource("1_jnfl3")
|
script = ExtResource("1_jnfl3")
|
||||||
|
|
||||||
|
[node name="NoteSpawner" type="Node" parent="." unique_id=885666554 node_paths=PackedStringArray("lanes", "pool", "notes")]
|
||||||
|
script = ExtResource("2_nuoj2")
|
||||||
|
lanes = {
|
||||||
|
0: NodePath("../Lane0"),
|
||||||
|
1: NodePath("../Lane1"),
|
||||||
|
2: NodePath("../Lane2"),
|
||||||
|
3: NodePath("../Lane3")
|
||||||
|
}
|
||||||
|
pool = NodePath("NotePool")
|
||||||
|
notes = NodePath("Notes")
|
||||||
|
metadata/_custom_type_script = "uid://dpu6645p40p43"
|
||||||
|
|
||||||
|
[node name="NotePool" type="Node" parent="NoteSpawner" unique_id=621311008]
|
||||||
|
script = ExtResource("10_74aio")
|
||||||
|
metadata/_custom_type_script = "uid://clog51kfg2rsb"
|
||||||
|
|
||||||
|
[node name="Notes" type="Node" parent="NoteSpawner" unique_id=936018806]
|
||||||
|
script = ExtResource("12_obbjr")
|
||||||
|
|
||||||
|
[node name="Note1" type="Node" parent="NoteSpawner/Notes" unique_id=577206015]
|
||||||
|
script = ExtResource("5_wq11w")
|
||||||
|
|
||||||
|
[node name="Note2" type="Node" parent="NoteSpawner/Notes" unique_id=1051280322]
|
||||||
|
script = ExtResource("5_wq11w")
|
||||||
|
hit_beat = 5.0
|
||||||
|
|
||||||
|
[node name="Note3" type="Node" parent="NoteSpawner/Notes" unique_id=1001463669]
|
||||||
|
script = ExtResource("5_wq11w")
|
||||||
|
hit_beat = 6.0
|
||||||
|
lane = 2
|
||||||
|
|
||||||
|
[node name="Lane0" type="Node2D" parent="." unique_id=178768598]
|
||||||
|
position = Vector2(394, 308)
|
||||||
|
script = ExtResource("4_obbjr")
|
||||||
|
metadata/_custom_type_script = "uid://u42y08gn6bi7"
|
||||||
|
|
||||||
|
[node name="Lane1" type="Node2D" parent="." unique_id=1477988197]
|
||||||
|
position = Vector2(516, 312)
|
||||||
|
script = ExtResource("4_obbjr")
|
||||||
|
metadata/_custom_type_script = "uid://u42y08gn6bi7"
|
||||||
|
|
||||||
|
[node name="Lane2" type="Node2D" parent="." unique_id=1586197762]
|
||||||
|
position = Vector2(634, 311)
|
||||||
|
script = ExtResource("4_obbjr")
|
||||||
|
metadata/_custom_type_script = "uid://u42y08gn6bi7"
|
||||||
|
|
||||||
|
[node name="Lane3" type="Node2D" parent="." unique_id=1689399295]
|
||||||
|
position = Vector2(778, 313)
|
||||||
|
script = ExtResource("4_obbjr")
|
||||||
|
metadata/_custom_type_script = "uid://u42y08gn6bi7"
|
||||||
|
|
||||||
[node name="Conductor" type="Node" parent="." unique_id=1726392948]
|
[node name="Conductor" type="Node" parent="." unique_id=1726392948]
|
||||||
script = ExtResource("2_62aw1")
|
script = ExtResource("2_62aw1")
|
||||||
autostart = true
|
autostart = true
|
||||||
@@ -32,17 +86,8 @@ stream = ExtResource("6_ecbku")
|
|||||||
script = ExtResource("7_nsyv8")
|
script = ExtResource("7_nsyv8")
|
||||||
metadata/_custom_type_script = "uid://bbpyym0kgujev"
|
metadata/_custom_type_script = "uid://bbpyym0kgujev"
|
||||||
|
|
||||||
[node name="AllChartNotes" type="Node" parent="." unique_id=2044386757]
|
[node name="VisibleNotes" type="Node" parent="." unique_id=149671562]
|
||||||
script = ExtResource("9_10cpq")
|
|
||||||
metadata/_custom_type_script = "uid://8isyo4pxyj1r"
|
|
||||||
|
|
||||||
[node name="VisibleNotes" type="Node" parent="." unique_id=149671562 node_paths=PackedStringArray("notes")]
|
|
||||||
script = ExtResource("9_74aio")
|
script = ExtResource("9_74aio")
|
||||||
notes = NodePath("../AllChartNotes")
|
|
||||||
metadata/_custom_type_script = "uid://c7h7ue6kjgoha"
|
metadata/_custom_type_script = "uid://c7h7ue6kjgoha"
|
||||||
|
|
||||||
[node name="NotePool" type="Node" parent="." unique_id=621311008]
|
|
||||||
script = ExtResource("10_74aio")
|
|
||||||
metadata/_custom_type_script = "uid://clog51kfg2rsb"
|
|
||||||
|
|
||||||
[connection signal="ticked" from="Conductor" to="Metronome" method="on_conductor_ticked"]
|
[connection signal="ticked" from="Conductor" to="Metronome" method="on_conductor_ticked"]
|
||||||
|
|||||||
9
rhythm_game/settings.gd
Normal file
9
rhythm_game/settings.gd
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
@abstract class_name Settings extends Object
|
||||||
|
|
||||||
|
## World coordinate units (pixels) per beat.
|
||||||
|
static func get_note_scroll_speed() -> float:
|
||||||
|
return _note_scroll_speed
|
||||||
|
|
||||||
|
|
||||||
|
# ======== IMPLEMENTATION ======== #
|
||||||
|
static var _note_scroll_speed: float = 20.0
|
||||||
1
rhythm_game/settings.gd.uid
Normal file
1
rhythm_game/settings.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://k0no5veq8xco
|
||||||
Reference in New Issue
Block a user