Skip to content

Instantly share code, notes, and snippets.

@DeerTears
Created November 16, 2021 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeerTears/946b2fe274b7529f2726bd656fbc0fb7 to your computer and use it in GitHub Desktop.
Save DeerTears/946b2fe274b7529f2726bd656fbc0fb7 to your computer and use it in GitHub Desktop.
code by me. CC0. I'm the bestest at naming functions :)
extends Node
func _ready():
$Timer.connect("timeout", self, "_on_timer_timeout")
func _on_timer_timeout() -> void:
if is_polygons_completely_overlapping(
offset_polygon($Small.polygon, $Small.position),
offset_polygon($Large.polygon, $Large.position)
):
foo()
static func is_polygons_completely_overlapping(a: PoolVector2Array, b: PoolVector2Array) -> bool:
var result: Array = Geometry.clip_polygons_2d(a, b)
return result.empty()
static func offset_polygon(polygon: PoolVector2Array, offset: Vector2) -> PoolVector2Array:
if polygon.empty():
return polygon
var new_polygon := PoolVector2Array([])
for point in polygon:
new_polygon.append(point + offset)
return new_polygon
func foo() -> void:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment