a game about throwing hammers made for the github game off
Diffstat (limited to 'autoloads/Utils.gd')
| -rw-r--r-- | autoloads/Utils.gd | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/autoloads/Utils.gd b/autoloads/Utils.gd new file mode 100644 index 0000000..b794b72 --- /dev/null +++ b/autoloads/Utils.gd @@ -0,0 +1,19 @@ +extends Node +class_name Util + + +func instance_scene_on_main(scene: PackedScene, position: Vector2) -> Node: + var main = get_tree().current_scene + var instance = scene.instantiate() + main.add_child(instance) + instance.global_position = position + return instance + + +static func str_vec(vec: Vector2) -> String: + var map := {Vector2.UP: "up", Vector2.DOWN: "down", Vector2.LEFT: "left", Vector2.RIGHT: "right"} + return map.get(vec, str(vec)) + + +static func sub(a: Array, b: Array) -> Array: + return a.filter(func(item) -> bool: return not item in b) |