PolyShape! Circle, Rectangle, Petals, and TreeTop all now inherit from PolyShape (:

This commit is contained in:
Harmony Honey 2023-01-06 03:57:21 -05:00
parent 8cdb5a6a17
commit 5120a367ec
15 changed files with 68 additions and 145 deletions

View file

@ -44,6 +44,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/actor/Player.gd"
}, {
"base": "CanvasItem",
"class": "PolyShape",
"language": "GDScript",
"path": "res://src/actor/shape/PolyShape.gd"
}, {
"base": "Resource",
"class": "SaveDict",
"language": "GDScript",
@ -127,6 +132,7 @@ _global_script_class_icons={
"MenuBase": "",
"PaletteSwap": "",
"Player": "",
"PolyShape": "",
"SaveDict": "",
"Scroll": "",
"SteamAPI": "",

View file

@ -7,16 +7,12 @@ self_modulate = Color( 1, 0.984314, 0, 1 )
polygon = PoolVector2Array( 25, 0, 23.097, 9.56709, 17.6777, 17.6777, 9.56709, 23.097, -1.09278e-06, 25, -9.56709, 23.097, -17.6777, 17.6777, -23.097, 9.56709, -25, -2.18557e-06, -23.097, -9.56709, -17.6777, -17.6777, -9.56709, -23.097, 2.98122e-07, -25, 9.56709, -23.097, 17.6777, -17.6777, 23.097, -9.56709 )
script = ExtResource( 1 )
radius = 25.0
poly_path = NodePath(".")
is_baked = true
[node name="Fill" type="Polygon2D" parent="."]
modulate = Color( 1, 0.866667, 0, 1 )
polygon = PoolVector2Array( 20, 0, 18.4776, 7.65367, 14.1421, 14.1421, 7.65367, 18.4776, -8.74228e-07, 20, -7.65367, 18.4776, -14.1421, 14.1421, -18.4776, 7.65367, -20, -1.74846e-06, -18.4776, -7.65367, -14.1421, -14.1421, -7.65367, -18.4776, 2.38498e-07, -20, 7.65367, -18.4776, 14.1421, -14.1421, 18.4776, -7.65367 )
script = ExtResource( 1 )
radius = 20.0
poly_path = NodePath(".")
is_baked = true
[node name="Hand" type="Line2D" parent="."]
points = PoolVector2Array( 0, -11, 0, 0, 7, 7 )

View file

@ -44,8 +44,6 @@ z_index = -25
polygon = PoolVector2Array( 75, 100, -75, 100, -75, -100, 75, -100 )
script = ExtResource( 4 )
size = Vector2( 75, 100 )
poly_path = NodePath(".")
is_baked = true
[node name="Rig" type="Node2D" parent="."]
light_mask = 4
@ -103,11 +101,11 @@ joint_mode = 2
begin_cap_mode = 2
end_cap_mode = 2
[node name="Stage" type="Node2D" parent="."]
modulate = Color( 1, 1, 1, 0 )
[node name="Stage" type="Polygon2D" parent="."]
material = SubResource( 6 )
z_index = 40
z_as_relative = false
polygon = PoolVector2Array( 1000, 1000, -1000, 1000, -1000, -1000, 1000, -1000 )
script = ExtResource( 4 )
size = Vector2( 1000, 1000 )

View file

@ -497,8 +497,6 @@ polygon = PoolVector2Array( 20, 0, 19.3185, 5.17638, 17.3205, 10, 14.1421, 14.14
script = ExtResource( 3 )
radius = 20.0
points = 24
poly_path = NodePath(".")
is_baked = true
[node name="Eyes" type="Node2D" parent="Sprites/Root/Body"]
modulate = Color( 1, 0, 1, 1 )
@ -511,8 +509,6 @@ script = ExtResource( 1 )
size = Vector2( 4, 7 )
radius = Plane( 4, -1, -1, -1 )
points = 4
poly_path = NodePath(".")
is_baked = true
[node name="Right" type="Polygon2D" parent="Sprites/Root/Body/Eyes"]
position = Vector2( 10, 0 )
@ -521,8 +517,6 @@ script = ExtResource( 1 )
size = Vector2( 4, 7 )
radius = Plane( 4, -1, -1, -1 )
points = 4
poly_path = NodePath(".")
is_baked = true
[node name="Hands" type="Node2D" parent="Sprites"]
modulate = Color( 0.478431, 0.25098, 0.423529, 1 )
@ -535,8 +529,6 @@ polygon = PoolVector2Array( 7.5, 0, 6.49519, 3.75, 3.75, 6.49519, -3.27835e-07,
script = ExtResource( 3 )
radius = 7.5
points = 12
poly_path = NodePath(".")
is_baked = true
[node name="Right" type="Polygon2D" parent="Sprites/Hands"]
use_parent_material = true
@ -545,8 +537,6 @@ polygon = PoolVector2Array( 7.5, 0, 6.49519, 3.75, 3.75, 6.49519, -3.27835e-07,
script = ExtResource( 3 )
radius = 7.5
points = 12
poly_path = NodePath(".")
is_baked = true
[node name="SpriteArea" type="Area2D" parent="Sprites"]
visible = false

View file

@ -44,8 +44,6 @@ polygon = PoolVector2Array( 100, 100, -100, 100, -100, -50, -98.7464, -61.126, -
script = ExtResource( 5 )
size = Vector2( 100, 100 )
radius = Plane( 0, 0, 50, 50 )
poly_path = NodePath(".")
is_baked = true
[node name="Knob" type="Polygon2D" parent="Sprites" index="1"]
modulate = Color( 1, 1, 0, 1 )
@ -55,8 +53,6 @@ script = ExtResource( 6 )
radius = 7.5
circle_offset = Vector2( 75, 0 )
points = 12
poly_path = NodePath(".")
is_baked = true
[node name="Knob2" type="Polygon2D" parent="Sprites" index="2"]
modulate = Color( 1, 1, 0, 1 )
@ -66,8 +62,6 @@ script = ExtResource( 6 )
radius = 7.5
circle_offset = Vector2( -75, 0 )
points = 12
poly_path = NodePath(".")
is_baked = true
[node name="Gem" type="Node2D" parent="Sprites" index="3"]
visible = false

View file

@ -35,8 +35,6 @@ script = ExtResource( 2 )
size = Vector2( 40, 50 )
radius = Plane( 0, 0, 20, 20 )
points = 6
poly_path = NodePath(".")
is_baked = true
[node name="Open" type="Node2D" parent="Sprites" index="1"]
position = Vector2( -40, 0 )
@ -48,8 +46,6 @@ polygon = PoolVector2Array( 7.5, 0, 6.49519, 3.75, 3.75, 6.49519, -3.27835e-07,
script = ExtResource( 6 )
radius = 7.5
points = 12
poly_path = NodePath(".")
is_baked = true
[node name="Gem" parent="Sprites/Open" index="1" instance=ExtResource( 5 )]
position = Vector2( 40, -5 )
@ -61,6 +57,6 @@ color = Color( 1, 0, 0.913725, 1 )
[node name="Clock" parent="Sprites/Open" index="2" instance=ExtResource( 4 )]
visible = false
position = Vector2( 40, -5 )
polygon = PoolVector2Array( 25, 0, 23.097, 9.56709, 17.6777, 17.6777, 9.56709, 23.097, -1.09278e-06, 25, -9.56709, 23.097, -17.6777, 17.6777, -23.097, 9.56709, -25, -2.18557e-06, -23.097, -9.56709, -17.6777, -17.6777, -9.56709, -23.097, 2.98122e-07, -25, 9.56709, -23.097, 17.6777, -17.6777, 23.097, -9.56709 )
polygon = PoolVector2Array( 50, 0, 46.194, 19.1342, 35.3553, 35.3553, 19.1342, 46.194, -2.18557e-06, 50, -19.1342, 46.194, -35.3553, 35.3553, -46.194, 19.1342, -50, -4.37114e-06, -46.194, -19.1342, -35.3553, -35.3553, -19.1342, -46.194, 5.96244e-07, -50, 19.1342, -46.194, 35.3553, -35.3553, 46.194, -19.1342 )
[editable path="Sprites/Open/Gem"]

View file

@ -1,34 +1,17 @@
tool
extends CanvasItem
extends PolyShape
export var radius := 50.0 setget set_radius
export var circle_offset := Vector2.ZERO setget set_offset
var gon := PoolVector2Array()
export var points := 16 setget set_points
export var poly_path : NodePath setget set_poly
onready var poly := get_node_or_null(poly_path)
export var is_baked := false
func _draw():
if !is_poly and gon.size() > 2: draw_colored_polygon(gon, Color.white, PoolVector2Array(), null, null, true)
func u():
if is_baked: return
func shape():
gon = []
for i in points:
gon.append(circle_offset + (radius * Vector2.RIGHT.rotated(TAU * (float(i) / points))))
if !poly: poly = get_node_or_null(poly_path)
if poly and "polygon" in poly:
poly.polygon = gon
if Engine.editor_hint:
property_list_changed_notify()
update()
func _draw():
if !poly: draw_colored_polygon(gon, Color.white, PoolVector2Array(), null, null, true)
func set_radius(arg := radius):
radius = abs(arg)
@ -41,7 +24,3 @@ func set_offset(arg := circle_offset):
func set_points(arg := points):
points = max(arg, 3)
u()
func set_poly(arg := poly_path):
poly_path = arg
u()

View file

@ -1,20 +1,15 @@
tool
extends CanvasItem
var gon := PoolVector2Array()
extends PolyShape
export var width := 8.5 setget set_width
export var length := 17.0 setget set_length
export var points := 5 setget set_points
export var offset := Vector2.ZERO setget set_offset
export var poly_path : NodePath setget set_poly
onready var poly := get_node_or_null(poly_path)
export var is_baked := false
func u():
if is_baked: return
func _draw():
if !is_poly and gon.size() > 2: draw_colored_polygon(gon, Color.white, PoolVector2Array(), null, null, true)
func shape():
gon = []
for i in 4:
@ -25,18 +20,7 @@ func u():
var s = Vector2(length, 0).rotated(r)
for y in points + 1:
gon.append(s + Vector2(width, 0).rotated(r + lerp(-PI*.5, PI*.5, float(y) / points)))
if !poly: poly = get_node_or_null(poly_path)
if poly and "polygon" in poly:
poly.polygon = gon
if Engine.editor_hint:
property_list_changed_notify()
update()
func _draw():
if !poly: draw_colored_polygon(gon, Color.white, PoolVector2Array(), null, null, true)
func set_width(arg := width):
width = arg
u()
@ -52,7 +36,3 @@ func set_offset(arg := offset):
func set_points(arg := points):
points = max(arg, 1)
u()
func set_poly(arg := poly_path):
poly_path = arg
u()

View file

@ -0,0 +1,34 @@
tool
extends CanvasItem
class_name PolyShape
var gon := PoolVector2Array()
var is_poly := false
export var poly_path : NodePath = "." setget set_poly
onready var poly := get_node_or_null(poly_path)
export var is_baked := true setget set_baked
func u():
if !poly: poly = get_node_or_null(poly_path)
is_poly = poly and "polygon" in poly
if is_baked and is_poly: return
shape()
if is_poly: poly.polygon = gon
if Engine.editor_hint:
property_list_changed_notify()
update()
func shape():
pass
func set_poly(arg := poly_path):
poly_path = arg
poly = null
u()
func set_baked(arg := is_baked):
is_baked = arg
if !arg: u()

View file

@ -1,20 +1,15 @@
tool
extends CanvasItem
var gon := PoolVector2Array()
extends PolyShape
export var size := Vector2.ONE * 50 setget set_size
export var offset := Vector2.ZERO setget set_offset
export var radius := Plane() setget set_radius
export var points := 8 setget set_points
export var poly_path : NodePath setget set_poly
onready var poly := get_node_or_null(poly_path)
export var is_baked := false
func u():
if is_baked: return
func _draw():
if !is_poly and gon.size() > 2: draw_colored_polygon(gon, Color.white, PoolVector2Array(), null, null, true)
func shape():
gon = []
var vec = [Vector2.ONE, Vector2(-1, 1), -Vector2.ONE, Vector2(1, -1)]
@ -31,18 +26,7 @@ func u():
gon.append(offset + v + Vector2(r, 0).rotated(a))
else:
gon.append(offset + vec[i] * size)
if !poly: poly = get_node_or_null(poly_path)
if poly and "polygon" in poly:
poly.polygon = gon
if Engine.editor_hint:
property_list_changed_notify()
update()
func _draw():
if !poly: draw_colored_polygon(gon, Color.white, PoolVector2Array(), null, null, true)
func set_offset(arg := offset):
offset = arg
u()
@ -59,9 +43,5 @@ func set_radius(arg := radius):
radius = arg
u()
func set_poly(arg := poly_path):
poly_path = arg
u()
func get_rect():
return Rect2(offset - size, size * 2.0)

View file

@ -1,23 +1,25 @@
tool
extends CanvasItem
extends PolyShape
export var leaves := 8 setget set_leaves
export var dist := 130.0 setget set_dist
export var radius := 70.0 setget set_radius
export var points := 8 setget set_points
export var draw_offset := Vector2.ZERO setget set_offset
var gon := PoolVector2Array()
export var poly_path : NodePath setget set_poly
onready var poly := get_node_or_null(poly_path)
export var is_baked := false
export var is_draw_debug := false setget set_debug
var _draw_me := Vector2.ZERO
var _draw_circle := Vector2.ZERO
func u():
if is_baked: return
func _draw():
if !is_poly and gon.size() > 2: draw_colored_polygon(gon, Color.white, PoolVector2Array(), null, null, true)
if is_draw_debug:
var c = Color(0,0,0, 0.5)
draw_line(Vector2.ZERO, Vector2(dist * 2, 0), c, 5.0)
draw_line(Vector2.ZERO, _draw_me, c, 5.0)
draw_circle(_draw_me, 10, c)
draw_circle(_draw_circle, radius, c)
func shape():
gon = []
var s = Vector2(dist, 0)
@ -37,23 +39,6 @@ func u():
var a = (float(i) / leaves) * TAU
for y in points:
gon.append(draw_offset + s.rotated(a) + Vector2(radius, 0).rotated(a + lerp(-ang, ang, float(y) / points)))
if !poly: poly = get_node_or_null(poly_path)
if poly and "polygon" in poly:
poly.polygon = gon
if Engine.editor_hint:
property_list_changed_notify()
update()
func _draw():
if !poly and gon.size() > 2: draw_colored_polygon(gon, Color.white, PoolVector2Array(), null, null, true)
if is_draw_debug:
var c = Color(0,0,0, 0.5)
draw_line(Vector2.ZERO, Vector2(dist * 2, 0), c, 5.0)
draw_line(Vector2.ZERO, _draw_me, c, 5.0)
draw_circle(_draw_me, 10, c)
draw_circle(_draw_circle, radius, c)
func set_leaves(arg := leaves):
leaves = max(1, arg)
@ -75,10 +60,6 @@ func set_offset(arg := draw_offset):
draw_offset = arg
u()
func set_poly(arg := poly_path):
poly_path = arg
u()
func set_debug(arg := is_draw_debug):
is_draw_debug = arg
u()

View file

@ -16,8 +16,6 @@ position = Vector2( 0, 28.5 )
polygon = PoolVector2Array( 35, 0, 32.3358, 13.3939, 24.7487, 24.7487, 13.3939, 32.3358, -1.5299e-06, 35, -13.3939, 32.3358, -24.7487, 24.7487, -32.3358, 13.3939, -35, -3.0598e-06, -32.3358, -13.3939, -24.7487, -24.7487, -13.3939, -32.3358, 4.17371e-07, -35, 13.3939, -32.3358, 24.7487, -24.7487, 32.3358, -13.3939 )
script = ExtResource( 4 )
radius = 35.0
poly_path = NodePath(".")
is_baked = true
[node name="FlowerPetals" parent="." instance=ExtResource( 1 )]
z_index = 0

View file

@ -37,8 +37,6 @@ script = ExtResource( 2 )
size = Vector2( 6.5, 31.5 )
radius = Plane( 6.49, -1, 0, 0 )
points = 4
poly_path = NodePath(".")
is_baked = true
[node name="Petals" type="Polygon2D" parent="Images"]
modulate = Color( 1, 0, 0, 1 )
@ -46,8 +44,6 @@ position = Vector2( 0, -50 )
rotation = 0.785398
polygon = PoolVector2Array( 8.5, -8.5, 17, -8.5, 21.9962, -6.87664, 25.084, -2.62664, 25.084, 2.62664, 21.9962, 6.87664, 17, 8.5, 8.5, 8.5, 8.5, 17, 6.87664, 21.9962, 2.62664, 25.084, -2.62665, 25.084, -6.87665, 21.9962, -8.5, 17, -8.5, 8.5, -17, 8.5, -21.9962, 6.87664, -25.084, 2.62664, -25.084, -2.62665, -21.9962, -6.87665, -17, -8.5, -8.5, -8.5, -8.5, -17, -6.87664, -21.9962, -2.62665, -25.084, 2.62665, -25.084, 6.87664, -21.9962, 8.5, -17 )
script = ExtResource( 1 )
poly_path = NodePath(".")
is_baked = true
[node name="Area2D" type="Area2D" parent="."]
visible = false

View file

@ -5,7 +5,6 @@
[ext_resource path="res://media/audio/sfx/guitar_pluck.wav" type="AudioStream" id=3]
[ext_resource path="res://src/detail/Spring.gd" type="Script" id=4]
[sub_resource type="CircleShape2D" id=1]
radius = 35.0
@ -34,7 +33,6 @@ rotation = 0.785397
polygon = PoolVector2Array( 8.5, -8.5, 17, -8.5, 21.9962, -6.87664, 25.084, -2.62664, 25.084, 2.62664, 21.9962, 6.87664, 17, 8.5, 8.5, 8.5, 8.5, 17, 6.87664, 21.9962, 2.62664, 25.084, -2.62665, 25.084, -6.87665, 21.9962, -8.5, 17, -8.5, 8.5, -17, 8.5, -21.9962, 6.87664, -25.084, 2.62664, -25.084, -2.62665, -21.9962, -6.87665, -17, -8.5, -8.5, -8.5, -8.5, -17, -6.87664, -21.9962, -2.62665, -25.084, 2.62665, -25.084, 6.87664, -21.9962, 8.5, -17 )
script = ExtResource( 2 )
poly_path = NodePath(".")
is_baked = true
[node name="Area2D" type="Area2D" parent="."]
visible = false

View file

@ -5,7 +5,6 @@
[ext_resource path="res://media/audio/sfx/btn0.wav" type="AudioStream" id=3]
[ext_resource path="res://src/detail/Spring.gd" type="Script" id=4]
[sub_resource type="CircleShape2D" id=1]
radius = 175.0
@ -32,8 +31,6 @@ modulate = Color( 0.494118, 0.890196, 0.337255, 1 )
antialiased = true
polygon = PoolVector2Array( 156.458, -64.8071, 174.201, -54.2799, 188.104, -39.0379, 196.96, -20.4052, 200, 0, 196.96, 20.4052, 188.104, 39.0379, 174.201, 54.2799, 156.458, 64.8072, 161.56, 84.7968, 160.613, 105.405, 153.7, 124.843, 141.421, 141.421, 124.843, 153.7, 105.405, 160.613, 84.7968, 161.56, 64.8071, 156.458, 54.2799, 174.201, 39.0379, 188.104, 20.4052, 196.96, -8.74228e-06, 200, -20.4052, 196.96, -39.0379, 188.104, -54.2799, 174.201, -64.8072, 156.458, -84.7968, 161.56, -105.405, 160.613, -124.843, 153.7, -141.421, 141.421, -153.7, 124.843, -160.613, 105.405, -161.56, 84.7968, -156.458, 64.8071, -174.201, 54.2799, -188.104, 39.0379, -196.96, 20.4052, -200, -1.74846e-05, -196.96, -20.4052, -188.104, -39.038, -174.201, -54.2799, -156.458, -64.8072, -161.56, -84.7968, -160.613, -105.405, -153.7, -124.843, -141.421, -141.421, -124.843, -153.7, -105.405, -160.613, -84.7968, -161.56, -64.8071, -156.458, -54.2799, -174.201, -39.038, -188.104, -20.4052, -196.96, 2.38498e-06, -200, 20.4052, -196.96, 39.0379, -188.104, 54.2799, -174.201, 64.8071, -156.458, 84.7968, -161.56, 105.405, -160.613, 124.843, -153.7, 141.421, -141.421, 153.7, -124.843, 160.613, -105.405, 161.56, -84.7968 )
script = ExtResource( 1 )
poly_path = NodePath(".")
is_baked = true
[node name="Area2D" type="Area2D" parent="."]
visible = false