Created
November 16, 2021 03:32
-
-
Save DeerTears/946b2fe274b7529f2726bd656fbc0fb7 to your computer and use it in GitHub Desktop.
code by me. CC0. I'm the bestest at naming functions :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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