diff --git a/RadialGame.tscn b/RadialGame.tscn index a5f6f47..234438b 100644 --- a/RadialGame.tscn +++ b/RadialGame.tscn @@ -102,10 +102,8 @@ __meta__ = { } [node name="NoteHandler" type="Control" parent="Square"] -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 +anchor_right = 1.0 +anchor_bottom = 1.0 script = ExtResource( 8 ) __meta__ = { "_edit_use_anchors_": false @@ -132,9 +130,14 @@ material = SubResource( 2 ) [node name="notelines" type="MeshInstance2D" parent="Square/NoteHandler/Viewport/Center"] material = SubResource( 3 ) -[node name="Painter" type="Node2D" parent="Square/NoteHandler"] +[node name="Painter" type="Control" parent="Square"] material = SubResource( 4 ) +anchor_right = 1.0 +anchor_bottom = 1.0 script = ExtResource( 6 ) +__meta__ = { +"_edit_use_anchors_": false +} [node name="Menu" parent="Square" instance=ExtResource( 15 )] anchor_right = 1.0 @@ -159,5 +162,6 @@ __meta__ = { "_edit_use_anchors_": false } +[connection signal="item_rect_changed" from="Square" to="Square/NoteHandler/Viewport" method="_on_Square_item_rect_changed"] [connection signal="column_pressed" from="Square/InputHandler" to="Square/NoteHandler" method="_on_InputHandler_column_pressed"] [connection signal="column_released" from="Square/InputHandler" to="Square/NoteHandler" method="_on_InputHandler_column_released"] diff --git a/scripts/InputHandler.gd b/scripts/InputHandler.gd index 6e323ce..73df6e9 100644 --- a/scripts/InputHandler.gd +++ b/scripts/InputHandler.gd @@ -40,8 +40,9 @@ func _check_buttons(touch_positions): var global_center = rect_global_position + rect_size*0.5 for pos in touch_positions: pos -= global_center + pos /= rect_size.x * 0.5 var pol = cartesian2polar(pos.x, pos.y) - var dist = pol.x/GameTheme.receptor_ring_radius + var dist = pol.x/GameTheme.receptor_ring_radius_normalized var angle = rad2deg(pol.y) if dist < TOUCHBUTTON_MIN_DIST: # Short circuit out to save some logic continue diff --git a/scripts/Menu.gd b/scripts/Menu.gd index 846c255..c00cb41 100644 --- a/scripts/Menu.gd +++ b/scripts/Menu.gd @@ -7,7 +7,7 @@ export var ReceptorsPath := @'../Center/Receptors' onready var NoteHandler := get_node(NoteHandlerPath) onready var Receptors := get_node(ReceptorsPath) onready var ScoreText := $ScoreText -onready var PVMusic := $PVMusic +onready var PVMusic := SoundPlayer.music_player_pv var genres = {} diff --git a/scripts/NoteHandler.gd b/scripts/NoteHandler.gd index 20369b7..482e40c 100644 --- a/scripts/NoteHandler.gd +++ b/scripts/NoteHandler.gd @@ -10,7 +10,7 @@ var song_key = '' onready var MusicPlayer := SoundPlayer.music_player onready var VideoPlayer := Video.video -onready var Painter = $Painter +onready var Painter = $'../Painter' onready var SlideTrailHandler = $'Viewport/Center/SlideTrailHandler' onready var JudgeText = $'Viewport/Center/JudgeText' onready var notelines = $'Viewport/Center/notelines' @@ -399,10 +399,13 @@ func _input(event): else: return + pos /= rect_size*0.5 # Normalize to unit circle + pos -= Vector2(1.0, 1.0) # Normalize to center + pos *= GameTheme.receptor_ring_radius_normalized_inv # Normalize to receptor ring as slides are for i in range(len(active_slide_trails)-1, -1, -1): # Iterate backwards as we are potentially deleting entries var note = active_slide_trails[i] - var center = note.get_position(note.progress) * GameTheme.receptor_ring_radius - var center2 = note.get_position(min(note.progress+0.06, 1.0)) * GameTheme.receptor_ring_radius + var center = note.get_position(note.progress) + var center2 = note.get_position(min(note.progress+0.06, 1.0)) if ((pos - center).length_squared() < Rules.SLIDE_RADIUS2) or ((pos - center2).length_squared() < Rules.SLIDE_RADIUS2): note.progress += 0.09 if note.progress >= 1.0: diff --git a/scripts/NotePainter.gd b/scripts/NotePainter.gd index 9f2a309..04aa082 100644 --- a/scripts/NotePainter.gd +++ b/scripts/NotePainter.gd @@ -1,6 +1,7 @@ -extends Node2D +extends Control -onready var Viewport := get_node(@'../Viewport') +onready var Viewport := get_node(@'../NoteHandler/Viewport') func _draw(): - draw_texture_rect(Viewport.get_texture(), Rect2(-540, -540, 1080, 1080), false) + draw_texture_rect(Viewport.get_texture(), Rect2(Vector2.ZERO, rect_size), false) +# texture = Viewport.get_texture() diff --git a/scripts/NoteViewport.gd b/scripts/NoteViewport.gd index 3b0d6a2..df4165f 100644 --- a/scripts/NoteViewport.gd +++ b/scripts/NoteViewport.gd @@ -1,11 +1,12 @@ extends Viewport -onready var base_height = ProjectSettings.get_setting('display/window/size/height') +onready var base_height = 1080.0 +var container_size := Vector2(1080, 1080) +var scale := Vector2(1, 1) func set_render_scale(scale: Vector2): - var ws = OS.window_size - var dim = min(ws.x, ws.y) - size = Vector2(dim, dim) * scale + self.scale = scale + size = container_size * scale $Center.position = size * 0.5 $Center.scale = size/base_height @@ -13,3 +14,12 @@ func set_render_scale(scale: Vector2): func _ready(): Settings.connect('subsampling_changed', self, 'set_render_scale') set_render_scale(Settings.subsampling) + + +onready var Square := $'../../' +onready var Root := $'/root' +onready var Main := $'/root/main' +func _on_Square_item_rect_changed() -> void: + var winscale = Root.size.x/Main.rect_size.x + container_size = Square.rect_size * winscale + set_render_scale(scale) diff --git a/scripts/Receptors.gd b/scripts/Receptors.gd index 9f30ec2..332d419 100644 --- a/scripts/Receptors.gd +++ b/scripts/Receptors.gd @@ -111,6 +111,19 @@ func update_ring_mesh(): temp_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, mesh_arrays) mesh = temp_mesh +func set_ring_vertex_count(num: int): + assert(num > 3) + ring_vertex_count = num + update_ring_mesh() + +func set_ring_skew(skew: int): + ring_skew = skew + update_ring_mesh() + +func set_receptor_positions(skew:=0.0): + material.set_shader_param("num_receptors", Rules.COLS) + material.set_shader_param("receptor_offset", PI/Rules.COLS) + func _draw(): # draw_old(true, true) @@ -131,20 +144,9 @@ func _draw(): material.set_shader_param("shadow_color", shadow_color) material.set_shader_param("alpha", alpha) - draw_mesh(mesh, null, null, Transform2D(0.0, rect_size*0.5)) - -func set_ring_vertex_count(num: int): - assert(num > 3) - ring_vertex_count = num - update_ring_mesh() - -func set_ring_skew(skew: int): - ring_skew = skew - update_ring_mesh() - -func set_receptor_positions(skew:=0.0): - material.set_shader_param("num_receptors", Rules.COLS) - material.set_shader_param("receptor_offset", PI/Rules.COLS) + var scale = rect_size.x/1080.0 + draw_mesh(mesh, null, null, Transform2D(Vector2(scale,0), Vector2(0,scale), rect_size*0.5)) #rect_size*0.5)) +# draw_mesh(mesh, null, null, Transform2D(0.0, rect_size*0.5)) func _ready(): add_child(tween) @@ -154,7 +156,7 @@ func _ready(): $"/root".connect("size_changed", self, "update") func set_alpha(a): - alpha = a + alpha = 1.0 #a material.set_shader_param("alpha", alpha) func fade(visible: bool): diff --git a/singletons/GameTheme.gd b/singletons/GameTheme.gd index 33c891e..dfa1de7 100644 --- a/singletons/GameTheme.gd +++ b/singletons/GameTheme.gd @@ -43,6 +43,8 @@ var pitch_judgement := { } var receptor_ring_radius := 460.0 +var receptor_ring_radius_normalized := 460.0/540.0 +var receptor_ring_radius_normalized_inv := 540.0/460.0 var note_forecast_beats := 2.0 # Notes start to appear this many beats before you need to tap them const INNER_NOTE_CIRCLE_RATIO := 0.3 # Notes under this far from the center will zoom into existence const SLIDE_DELAY := 0.5 #0.125 #0.5 # Time in beats between the tap of the star and the start of the visual slide diff --git a/singletons/Rules.gd b/singletons/Rules.gd index 079ad15..631e8d5 100644 --- a/singletons/Rules.gd +++ b/singletons/Rules.gd @@ -22,7 +22,8 @@ const JUDGEMENT_SCORES = [1.0, 0.9, 0.75, 0.5, 0.0] const SCORE_STRINGS = ['SSS', 'SS', 'S', 'A⁺', 'A', 'B⁺', 'B', 'C⁺', 'C', 'F'] const SCORE_CUTOFFS = [1.0, 0.975, 0.95, 0.9, 0.85, 0.8, 0.7, 0.6, 0.5] -const SLIDE_RADIUS2 = 10000.0 # Radius of 100px +const SLIDE_RADIUS := 100.0/540.0 # Radius of 100px at 1080p, normalized +const SLIDE_RADIUS2 = pow(SLIDE_RADIUS, 2) # Not really a fan of Simply Love grading # Scoring can probably be fine with a strictly positive scheme, but I really dislike having so many grades and the ± feels meaningless. diff --git a/singletons/SoundPlayer.gd b/singletons/SoundPlayer.gd index 4b448d3..a2fdec4 100644 --- a/singletons/SoundPlayer.gd +++ b/singletons/SoundPlayer.gd @@ -39,6 +39,9 @@ func play(type: int, parent: Node, stream: AudioStream, volume_db: float = 0.0, var music_player := AudioStreamPlayer.new() +var music_player_pv := AudioStreamPlayer.new() func _ready() -> void: add_child(music_player) music_player.bus = "Music" + add_child(music_player_pv) + music_player_pv.bus = "Preview"