Redid math to a zero center

This commit is contained in:
Luke Hubmayer-Werner 2019-11-18 13:11:02 +10:30
parent d1d68d1cdd
commit 3ed63d81b9
5 changed files with 35 additions and 26 deletions

View File

@ -1,27 +1,28 @@
extends "res://main.gd"
# Draw the bezel for radial gamemode
var center := Vector2(0.0, 0.0)
func _draw():
var bezel_color := Color.black
var bezel_colors := PoolColorArray([bezel_color])
var bezel_colors := PoolColorArray([theme.bezel_color])
var bezel_points: PoolVector2Array
var screen_height2 := screen_height/2.0
draw_rect(Rect2(0, 0, x_margin, screen_height), bezel_color)
draw_rect(Rect2(1920-x_margin, 0, x_margin, screen_height), bezel_color)
draw_rect(Rect2(-screen_height2, -screen_height2, -x_margin, screen_height), theme.bezel_color)
draw_rect(Rect2(screen_height2, -screen_height2, x_margin, screen_height), theme.bezel_color)
bezel_points = arc_point_list(screen_center, screen_height/2, 0, -90)
bezel_points.push_back(Vector2(1920-x_margin, 0))
bezel_points = arc_point_list(center, screen_height2, 0, -90)
bezel_points.push_back(Vector2(screen_height2, -screen_height2))
draw_polygon(bezel_points, bezel_colors)
bezel_points = arc_point_list(screen_center, screen_height/2, -90, -180)
bezel_points.push_back(Vector2(x_margin, 0))
bezel_points = arc_point_list(center, screen_height2, -90, -180)
bezel_points.push_back(Vector2(-screen_height2, -screen_height2))
draw_polygon(bezel_points, bezel_colors)
bezel_points = arc_point_list(screen_center, screen_height/2, -180, -270)
bezel_points.push_back(Vector2(x_margin, screen_height))
bezel_points = arc_point_list(center, screen_height2, -180, -270)
bezel_points.push_back(Vector2(-screen_height2, screen_height2))
draw_polygon(bezel_points, bezel_colors)
bezel_points = arc_point_list(screen_center, screen_height/2, -270, -360)
bezel_points.push_back(Vector2(1920-x_margin, screen_height))
bezel_points = arc_point_list(center, screen_height2, -270, -360)
bezel_points.push_back(Vector2(screen_height2, screen_height2))
draw_polygon(bezel_points, bezel_colors)

View File

@ -4,15 +4,15 @@ var ring_px := 4
var receptor_px := 24
var shadow_px := 5
var shadow_color := Color.black
var receptor_color := Color.blue
var center := Vector2(0.0, 0.0)
func _draw():
# Screen filter
draw_rect(Rect2(x_margin, 0, screen_height, screen_height), theme.screen_filter)
draw_rect(Rect2(-screen_height/2, -screen_height/2, screen_height, screen_height), theme.screen_filter)
# Receptor ring
var receptor_circle := arc_point_list(screen_center, theme.receptor_ring_radius, 0.0, 360.0, 360)
var receptor_centers := arc_point_list(screen_center, theme.receptor_ring_radius, Rules.FIRST_COLUMN_ANGLE_DEG, Rules.FIRST_COLUMN_ANGLE_DEG+360.0-Rules.COLS_ANGLE_DEG, Rules.COLS)
var receptor_circle := arc_point_list(center, theme.receptor_ring_radius, 0.0, 360.0, 360)
var receptor_centers := arc_point_list(center, theme.receptor_ring_radius, Rules.FIRST_COLUMN_ANGLE_DEG, Rules.FIRST_COLUMN_ANGLE_DEG+360.0-Rules.COLS_ANGLE_DEG, Rules.COLS)
# Shadows
for i in range(len(receptor_circle)-1):
@ -22,7 +22,7 @@ func _draw():
# Foregrounds
for i in range(len(receptor_circle)-1):
draw_line(receptor_circle[i], receptor_circle[i+1], receptor_color, ring_px, true)
draw_line(receptor_circle[i], receptor_circle[i+1], theme.receptor_color, ring_px, true)
for i in range(len(receptor_centers)):
draw_circle(receptor_centers[i], receptor_px/2, receptor_color)
draw_circle(receptor_centers[i], receptor_px/2, theme.receptor_color)

View File

@ -31,12 +31,17 @@ shader_param/held_color = null
shader_param/screen_size = null
[node name="main" type="Node2D"]
position = Vector2( 960, 540 )
script = ExtResource( 1 )
__meta__ = {
"_edit_vertical_guides_": [ 1450.0 ]
}
[node name="video" type="VideoPlayer" parent="."]
margin_left = 420.0
margin_right = 1500.0
margin_bottom = 1080.0
margin_left = -540.0
margin_top = -540.0
margin_right = 540.0
margin_bottom = 540.0
grow_horizontal = 2
grow_vertical = 2
rect_pivot_offset = Vector2( 540, 540 )
@ -52,7 +57,6 @@ __meta__ = {
script = ExtResource( 4 )
[node name="NoteHandler" type="Node2D" parent="."]
position = Vector2( 960, 540 )
script = ExtResource( 5 )
[node name="SlideTrailHandler" type="Node2D" parent="NoteHandler"]
@ -67,8 +71,10 @@ material = SubResource( 2 )
script = ExtResource( 8 )
[node name="InputHandler" type="Label" parent="."]
margin_right = 424.0
margin_bottom = 216.0
margin_left = -960.0
margin_top = -540.0
margin_right = 960.0
margin_bottom = 540.0
custom_fonts/font = ExtResource( 9 )
text = "Fingers on the screen:"
script = ExtResource( 10 )

View File

@ -34,6 +34,8 @@ var COLOR_ARRAY_DOUBLE_8 := PoolColorArray([
])
var screen_filter := Color(0.0, 0.0, 0.0, 0.2)
var receptor_color := Color.blue
var bezel_color := Color.black
var RADIAL_COL_ANGLES := PoolRealArray() # ideally const
var RADIAL_UNIT_VECTORS := PoolVector2Array() # ideally const

View File

@ -9,5 +9,5 @@ func update_aspect_ratio(ratio: float):
# e.g. for a 1920x1080 video you'd call update_aspect_ratio(1920.0/1080.0)
# e.g. for a 1440x1080 video you'd call update_aspect_ratio(1440.0/1080.0)
var height = 1080/ratio
margin_top = (1080 - height)/2.0
margin_bottom = margin_top + height
margin_top = -height/2.0
margin_bottom = height/2.0