[WIP] Refactoring RadialGame

Moving things away from entangled Node2Ds to proper Controls.
Should enable RadialGame to be placed wherever without bugs.
This commit is contained in:
Luke Hubmayer-Werner 2021-01-29 19:26:44 +10:30
parent cda5f5ac3b
commit fe27cdab0e
5 changed files with 65 additions and 136 deletions

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=18 format=2]
[ext_resource path="res://scripts/InputHandler.gd" type="Script" id=1]
[ext_resource path="res://assets/text-4k.png" type="Texture" id=2]
@ -27,27 +27,14 @@ shader_param/px = 0.00108696
shader_param/px2 = 0.00217391
shader_param/alpha = 1.0
[sub_resource type="ArrayMesh" id=2]
surfaces/0 = {
"aabb": AABB( -481.834, -481.834, 0, 963.667, 963.667, 0 ),
"array_data": PoolByteArray( 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0, 95, 168, 216, 67, 118, 207, 152, 66, 137, 59, 80, 49, 183, 65, 237, 67, 202, 86, 167, 66, 32, 60, 210, 49, 125, 187, 206, 67, 38, 125, 22, 67, 48, 59, 60, 53, 64, 99, 226, 67, 249, 203, 36, 67, 223, 59, 187, 53, 141, 134, 190, 67, 0, 0, 92, 67, 160, 58, 166, 55, 217, 163, 208, 67, 177, 234, 112, 67, 65, 59, 48, 56, 159, 135, 168, 67, 204, 105, 141, 67, 220, 57, 235, 56, 142, 141, 184, 67, 186, 219, 154, 67, 107, 58, 98, 57, 204, 105, 141, 67, 159, 135, 168, 67, 235, 56, 220, 57, 186, 219, 154, 67, 142, 141, 184, 67, 98, 57, 107, 58, 0, 0, 92, 67, 141, 134, 190, 67, 166, 55, 160, 58, 177, 234, 112, 67, 217, 163, 208, 67, 48, 56, 65, 59, 38, 125, 22, 67, 125, 187, 206, 67, 60, 53, 48, 59, 249, 203, 36, 67, 64, 99, 226, 67, 187, 53, 223, 59, 118, 207, 152, 66, 95, 168, 216, 67, 80, 49, 137, 59, 202, 86, 167, 66, 183, 65, 237, 67, 210, 49, 32, 60, 141, 172, 242, 40, 0, 0, 220, 67, 0, 0, 166, 59, 143, 223, 4, 41, 177, 234, 240, 67, 0, 0, 48, 60, 118, 207, 152, 194, 95, 168, 216, 67, 80, 177, 137, 59, 202, 86, 167, 194, 183, 65, 237, 67, 210, 177, 32, 60, 38, 125, 22, 195, 125, 187, 206, 67, 60, 181, 48, 59, 249, 203, 36, 195, 64, 99, 226, 67, 187, 181, 223, 59, 0, 0, 92, 195, 141, 134, 190, 67, 166, 183, 160, 58, 177, 234, 112, 195, 217, 163, 208, 67, 48, 184, 65, 59, 204, 105, 141, 195, 159, 135, 168, 67, 235, 184, 220, 57, 186, 219, 154, 195, 142, 141, 184, 67, 98, 185, 107, 58, 159, 135, 168, 195, 204, 105, 141, 67, 220, 185, 235, 56, 142, 141, 184, 195, 186, 219, 154, 67, 107, 186, 98, 57, 141, 134, 190, 195, 0, 0, 92, 67, 160, 186, 166, 55, 217, 163, 208, 195, 177, 234, 112, 67, 65, 187, 48, 56, 125, 187, 206, 195, 38, 125, 22, 67, 48, 187, 60, 53, 64, 99, 226, 195, 249, 203, 36, 67, 223, 187, 187, 53, 95, 168, 216, 195, 118, 207, 152, 66, 137, 187, 80, 49, 183, 65, 237, 195, 202, 86, 167, 66, 32, 188, 210, 49, 0, 0, 220, 195, 141, 172, 114, 41, 166, 187, 0, 0, 177, 234, 240, 195, 143, 223, 132, 41, 48, 188, 0, 0, 95, 168, 216, 195, 118, 207, 152, 194, 137, 187, 80, 177, 183, 65, 237, 195, 202, 86, 167, 194, 32, 188, 210, 177, 125, 187, 206, 195, 38, 125, 22, 195, 48, 187, 60, 181, 64, 99, 226, 195, 249, 203, 36, 195, 223, 187, 187, 181, 141, 134, 190, 195, 0, 0, 92, 195, 160, 186, 166, 183, 217, 163, 208, 195, 177, 234, 112, 195, 65, 187, 48, 184, 159, 135, 168, 195, 204, 105, 141, 195, 220, 185, 235, 184, 142, 141, 184, 195, 186, 219, 154, 195, 107, 186, 98, 185, 204, 105, 141, 195, 159, 135, 168, 195, 235, 184, 220, 185, 186, 219, 154, 195, 142, 141, 184, 195, 98, 185, 107, 186, 0, 0, 92, 195, 141, 134, 190, 195, 166, 183, 160, 186, 177, 234, 112, 195, 217, 163, 208, 195, 48, 184, 65, 187, 38, 125, 22, 195, 125, 187, 206, 195, 60, 181, 48, 187, 249, 203, 36, 195, 64, 99, 226, 195, 187, 181, 223, 187, 118, 207, 152, 194, 95, 168, 216, 195, 80, 177, 137, 187, 202, 86, 167, 194, 183, 65, 237, 195, 210, 177, 32, 188, 106, 1, 182, 169, 0, 0, 220, 195, 0, 0, 166, 187, 87, 79, 199, 169, 177, 234, 240, 195, 0, 0, 48, 188, 118, 207, 152, 66, 95, 168, 216, 195, 80, 49, 137, 187, 202, 86, 167, 66, 183, 65, 237, 195, 210, 49, 32, 188, 38, 125, 22, 67, 125, 187, 206, 195, 60, 53, 48, 187, 249, 203, 36, 67, 64, 99, 226, 195, 187, 53, 223, 187, 0, 0, 92, 67, 141, 134, 190, 195, 166, 55, 160, 186, 177, 234, 112, 67, 217, 163, 208, 195, 48, 56, 65, 187, 204, 105, 141, 67, 159, 135, 168, 195, 235, 56, 220, 185, 186, 219, 154, 67, 142, 141, 184, 195, 98, 57, 107, 186, 159, 135, 168, 67, 204, 105, 141, 195, 220, 57, 235, 184, 142, 141, 184, 67, 186, 219, 154, 195, 107, 58, 98, 185, 141, 134, 190, 67, 0, 0, 92, 195, 160, 58, 166, 183, 217, 163, 208, 67, 177, 234, 112, 195, 65, 59, 48, 184, 125, 187, 206, 67, 38, 125, 22, 195, 48, 59, 60, 181, 64, 99, 226, 67, 249, 203, 36, 195, 223, 59, 187, 181, 95, 168, 216, 67, 118, 207, 152, 194, 137, 59, 80, 177, 183, 65, 237, 67, 202, 86, 167, 194, 32, 60, 210, 177, 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0 ),
"array_index_data": PoolByteArray( ),
"blend_shape_data": [ ],
"format": 359441,
"index_count": 0,
"primitive": 5,
"skeleton_aabb": [ ],
"vertex_count": 74
}
[sub_resource type="ShaderMaterial" id=3]
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 11 )
shader_param/bps = null
shader_param/star_color = null
shader_param/held_color = null
shader_param/screen_size = null
[sub_resource type="ShaderMaterial" id=4]
[sub_resource type="ShaderMaterial" id=3]
shader = ExtResource( 10 )
shader_param/line_color = Color( 0.8, 0.8, 1, 0.8 )
shader_param/line_color_double = Color( 1, 1, 0.6, 0.9 )
@ -63,21 +50,25 @@ shader_param/array_postmul = Vector3( 1, 1, 1 )
shader_param/array_sidelen = 16
shader_param/array_size = 256
[sub_resource type="CanvasItemMaterial" id=5]
[sub_resource type="CanvasItemMaterial" id=4]
blend_mode = 4
[sub_resource type="Curve" id=6]
[sub_resource type="Curve" id=5]
min_value = -1.0
_data = [ Vector2( -1, -1 ), 0.0, 0.0, 0, 0, Vector2( 0, 0 ), 2.0, 2.0, 1, 1, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ]
[node name="RadialGame" type="Control"]
[node name="RadialGame" type="AspectRatioContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="video" type="TextureRect" parent="." groups=[
[node name="Square" type="Control" parent="."]
margin_right = 1080.0
margin_bottom = 1080.0
[node name="video" type="TextureRect" parent="Square" groups=[
"VideoTexRects",
]]
anchor_right = 1.0
@ -92,7 +83,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="ScreenFilter" type="ColorRect" parent="."]
[node name="ScreenFilter" type="ColorRect" parent="Square"]
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0, 0, 0, 1 )
@ -101,66 +92,66 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Center" type="Control" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
[node name="Receptors" type="Control" parent="Square"]
material = SubResource( 1 )
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 9 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Receptors" type="MeshInstance2D" parent="Center"]
material = SubResource( 1 )
mesh = SubResource( 2 )
script = ExtResource( 9 )
[node name="Tween" type="Tween" parent="Center/Receptors"]
[node name="NoteHandler" type="Node2D" parent="Center"]
[node name="NoteHandler" type="Control" parent="Square"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
script = ExtResource( 8 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Viewport" type="Viewport" parent="Center/NoteHandler"]
[node name="Viewport" type="Viewport" parent="Square/NoteHandler"]
size = Vector2( 1080, 1080 )
transparent_bg = true
usage = 1
render_target_v_flip = true
script = ExtResource( 5 )
[node name="Center" type="Node2D" parent="Center/NoteHandler/Viewport"]
[node name="Center" type="Node2D" parent="Square/NoteHandler/Viewport"]
position = Vector2( 540, 540 )
[node name="SlideTrailHandler" type="Node2D" parent="Center/NoteHandler/Viewport/Center"]
[node name="SlideTrailHandler" type="Node2D" parent="Square/NoteHandler/Viewport/Center"]
[node name="JudgeText" type="MeshInstance2D" parent="Center/NoteHandler/Viewport/Center"]
[node name="JudgeText" type="MeshInstance2D" parent="Square/NoteHandler/Viewport/Center"]
texture = ExtResource( 2 )
[node name="meshinstance" type="MeshInstance2D" parent="Center/NoteHandler/Viewport/Center"]
[node name="meshinstance" type="MeshInstance2D" parent="Square/NoteHandler/Viewport/Center"]
material = SubResource( 2 )
[node name="notelines" type="MeshInstance2D" parent="Square/NoteHandler/Viewport/Center"]
material = SubResource( 3 )
[node name="notelines" type="MeshInstance2D" parent="Center/NoteHandler/Viewport/Center"]
[node name="Painter" type="Node2D" parent="Square/NoteHandler"]
material = SubResource( 4 )
[node name="Painter" type="Node2D" parent="Center/NoteHandler"]
material = SubResource( 5 )
script = ExtResource( 6 )
[node name="Menu" parent="." instance=ExtResource( 15 )]
[node name="Menu" parent="Square" instance=ExtResource( 15 )]
anchor_right = 1.0
anchor_bottom = 1.0
ease_curve = SubResource( 6 )
NoteHandlerPath = NodePath("../NoteHandler")
ReceptorsPath = NodePath("../Receptors")
ease_curve = SubResource( 5 )
[node name="Bezel" type="Control" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
[node name="Bezel" type="Control" parent="Square"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 13 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="InputHandler" type="Control" parent="."]
[node name="InputHandler" type="Control" parent="Square"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
@ -168,5 +159,5 @@ __meta__ = {
"_edit_use_anchors_": false
}
[connection signal="column_pressed" from="InputHandler" to="Center/NoteHandler" method="_on_InputHandler_column_pressed"]
[connection signal="column_released" from="InputHandler" to="Center/NoteHandler" method="_on_InputHandler_column_released"]
[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"]

View File

@ -1,63 +0,0 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://shaders/notelines.shader" type="Shader" id=1]
[ext_resource path="res://shaders/notemesh.shader" type="Shader" id=2]
[ext_resource path="res://scripts/NoteHandler.gd" type="Script" id=3]
[ext_resource path="res://assets/text-4k.png" type="Texture" id=4]
[ext_resource path="res://scripts/NotePainter.gd" type="Script" id=5]
[ext_resource path="res://scripts/NoteViewport.gd" type="Script" id=6]
[sub_resource type="ShaderMaterial" id=3]
shader = ExtResource( 2 )
shader_param/bps = null
shader_param/star_color = null
shader_param/held_color = null
shader_param/screen_size = null
[sub_resource type="ShaderMaterial" id=4]
shader = ExtResource( 1 )
shader_param/line_color = Color( 0.8, 0.8, 1, 0.8 )
shader_param/line_color_double = Color( 1, 1, 0.6, 0.9 )
shader_param/dot_color = Color( 1, 1, 1, 0.8 )
shader_param/bps = 1.0
shader_param/line_thickness = 0.012
shader_param/line_thickness_min = 0.0
shader_param/dot_thickness = 0.033
shader_param/dot_fullbright_thickness = 0.013
shader_param/max_angle = 1.0708
shader_param/max_dist = 1.25
shader_param/array_postmul = Vector3( 1, 1, 1 )
shader_param/array_sidelen = 16
shader_param/array_size = 256
[sub_resource type="CanvasItemMaterial" id=5]
blend_mode = 4
[node name="NoteHandler" type="Node2D"]
script = ExtResource( 3 )
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 540, 540 )
transparent_bg = true
usage = 1
render_target_v_flip = true
script = ExtResource( 6 )
[node name="Center" type="Node2D" parent="Viewport"]
position = Vector2( 270, 270 )
scale = Vector2( 0.5, 0.5 )
[node name="SlideTrailHandler" type="Node2D" parent="Viewport/Center"]
[node name="JudgeText" type="MeshInstance2D" parent="Viewport/Center"]
texture = ExtResource( 4 )
[node name="meshinstance" type="MeshInstance2D" parent="Viewport/Center"]
material = SubResource( 3 )
[node name="notelines" type="MeshInstance2D" parent="Viewport/Center"]
material = SubResource( 4 )
[node name="Painter" type="Node2D" parent="."]
material = SubResource( 5 )
script = ExtResource( 5 )

View File

@ -12,31 +12,26 @@ func arc_point_list(center: Vector2, radius: float, angle_from:=0.0, angle_to:=3
return point_list
func _draw():
center = rect_size*0.5
var bezel_colors := PoolColorArray([GameTheme.bezel_color])
var bezel_points: PoolVector2Array
var dim = rect_size.x
var dim2 = center.x
var screen_size = $"/root".get_visible_rect().size
var screen_height = 1080 # min(screen_size.x, screen_size.y)
var screen_height2 = screen_height/2.0
# draw_rect(Rect2(-screen_height2, -screen_height2, -x_margin, screen_height), GameTheme.bezel_color)
# draw_rect(Rect2(screen_height2, -screen_height2, x_margin, screen_height), GameTheme.bezel_color)
bezel_points = arc_point_list(center, screen_height2, 0, -90)
bezel_points.push_back(Vector2(screen_height2, -screen_height2))
bezel_points = arc_point_list(center, dim2, 0, -90)
bezel_points.push_back(Vector2(dim, 0))
draw_polygon(bezel_points, bezel_colors)
bezel_points = arc_point_list(center, screen_height2, -90, -180)
bezel_points.push_back(Vector2(-screen_height2, -screen_height2))
bezel_points = arc_point_list(center, dim2, -90, -180)
bezel_points.push_back(Vector2(0, 0))
draw_polygon(bezel_points, bezel_colors)
bezel_points = arc_point_list(center, screen_height2, -180, -270)
bezel_points.push_back(Vector2(-screen_height2, screen_height2))
bezel_points = arc_point_list(center, dim2, -180, -270)
bezel_points.push_back(Vector2(0, dim))
draw_polygon(bezel_points, bezel_colors)
bezel_points = arc_point_list(center, screen_height2, -270, -360)
bezel_points.push_back(Vector2(screen_height2, screen_height2))
bezel_points = arc_point_list(center, dim2, -270, -360)
bezel_points.push_back(Vector2(dim, dim))
draw_polygon(bezel_points, bezel_colors)
func _ready():

View File

@ -1,4 +1,4 @@
extends Node2D
extends Control
var screen_height := 1080

View File

@ -1,5 +1,8 @@
tool
extends MeshInstance2D
extends Control
var tween := Tween.new()
var mesh := Mesh.new()
export var ring_px := 4 # Analogous to diameter
export var receptor_px := 24 # Diameter
@ -128,6 +131,8 @@ 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
@ -142,6 +147,7 @@ func set_receptor_positions(skew:=0.0):
material.set_shader_param("receptor_offset", PI/Rules.COLS)
func _ready():
add_child(tween)
set_receptor_positions()
update_ring_mesh()
set_alpha(float(Engine.editor_hint))
@ -152,5 +158,5 @@ func set_alpha(a):
material.set_shader_param("alpha", alpha)
func fade(visible: bool):
$Tween.interpolate_method(self, "set_alpha", alpha, float(visible), abs(alpha-float(visible))*2.0)
$Tween.start()
tween.interpolate_method(self, "set_alpha", alpha, float(visible), abs(alpha-float(visible))*2.0)
tween.start()