RhythmGame/scripts/Bezel.gd

39 lines
1.2 KiB
GDScript3
Raw Normal View History

tool
extends Control
2019-11-10 15:09:14 +10:30
# Draw the bezel for radial gamemode
2019-11-18 13:11:02 +10:30
var center := Vector2(0.0, 0.0)
2019-11-10 15:09:14 +10:30
func arc_point_list(center: Vector2, radius: float, angle_from:=0.0, angle_to:=360.0, points:=20) -> PoolVector2Array:
var point_list = PoolVector2Array()
for i in range(points):
var angle = deg2rad(angle_from + i * (angle_to - angle_from) / (points-1))
point_list.push_back(center + polar2cartesian(radius, angle))
return point_list
2019-11-10 15:09:14 +10:30
func _draw():
center = rect_size*0.5
2020-03-12 23:05:12 +10:30
var bezel_colors := PoolColorArray([GameTheme.bezel_color])
2019-11-10 15:09:14 +10:30
var bezel_points: PoolVector2Array
var dim = rect_size.x
var dim2 = center.x
2020-03-12 23:05:12 +10:30
bezel_points = arc_point_list(center, dim2, 0, -90)
bezel_points.push_back(Vector2(dim, 0))
2019-11-10 15:09:14 +10:30
draw_polygon(bezel_points, bezel_colors)
bezel_points = arc_point_list(center, dim2, -90, -180)
bezel_points.push_back(Vector2(0, 0))
2019-11-10 15:09:14 +10:30
draw_polygon(bezel_points, bezel_colors)
bezel_points = arc_point_list(center, dim2, -180, -270)
bezel_points.push_back(Vector2(0, dim))
2019-11-10 15:09:14 +10:30
draw_polygon(bezel_points, bezel_colors)
bezel_points = arc_point_list(center, dim2, -270, -360)
bezel_points.push_back(Vector2(dim, dim))
2019-11-10 15:09:14 +10:30
draw_polygon(bezel_points, bezel_colors)
func _ready():
2020-03-12 23:05:12 +10:30
$"/root".connect("size_changed", self, "update")