a game about throwing hammers made for the github game off
Diffstat (limited to 'autoloads/Utils.gd')
| -rw-r--r-- | autoloads/Utils.gd | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/autoloads/Utils.gd b/autoloads/Utils.gd index 2b9321b..d04df53 100644 --- a/autoloads/Utils.gd +++ b/autoloads/Utils.gd @@ -1,6 +1,8 @@ extends Node class_name Util +static func is_in_range(val: float, start: float, end: float) -> bool: + return val > start and val < end static func instance_scene(scene: PackedScene, position: Vector2, on: Node) -> Node: var instance := scene.instantiate() as Node2D @@ -8,7 +10,6 @@ static func instance_scene(scene: PackedScene, position: Vector2, on: Node) -> N instance.global_position = position return instance - func instance_scene_on_main(scene: PackedScene, position: Vector2) -> Node: return Util.instance_scene(scene, position, get_tree().current_scene) @@ -19,15 +20,12 @@ 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) - static func out_of_bounds(v: Vector2i, rect: Vector2i) -> bool: return v.x > rect.x or v.y > rect.y or v.x < 0 or v.y < 0 - const hammer_path_fmt := "res://hammers/hammer_%s.tscn" const hammers: Array[PackedScene] = [ preload(hammer_path_fmt % "01"), |