a game about throwing hammers made for the github game off
fix various warnings
bendn 2022-11-27
parent d0ffe59 · commit 4f0bb57
-rw-r--r--autoloads/Utils.gd18
-rw-r--r--player/player.gd2
-rw-r--r--ui/components/aim/aim.gd2
-rw-r--r--ui/graphics.gd20
-rw-r--r--ui/hud/health_meter.gd1
5 files changed, 22 insertions, 21 deletions
diff --git a/autoloads/Utils.gd b/autoloads/Utils.gd
index 484e146..631d2b0 100644
--- a/autoloads/Utils.gd
+++ b/autoloads/Utils.gd
@@ -1,6 +1,24 @@
extends Node
class_name Util
+static func dict_cmp(d1: Dictionary, d2: Dictionary) -> bool:
+ return (
+ len(d1) == len(d2)
+ and sort(d1.keys()) == sort(d2.keys())
+ and value_types(d1.values()) == value_types(d2.values())
+ )
+
+static func sort(arr: Array) -> Array:
+ arr.sort()
+ return arr
+
+static func value_types(arr: Array) -> Array:
+ var types = []
+ for value in arr:
+ types.append(typeof(value))
+ types.sort()
+ return types
+
static func is_in_range(val: float, start: float, end: float) -> bool:
return val >= start and val <= end
diff --git a/player/player.gd b/player/player.gd
index fac7978..7c4a90f 100644
--- a/player/player.gd
+++ b/player/player.gd
@@ -301,7 +301,7 @@ func disable_aim_gizmo() -> void:
## Throws the hammer.
func throw(rot: float) -> void:
- rot + randf_range(-0.01, 0.01)
+ rot += randf_range(-0.01, 0.01)
remove_child(current_hammer)
current_hammer.position.x = 0 # center
current_hammer.global_position = to_global(current_hammer.position)
diff --git a/ui/components/aim/aim.gd b/ui/components/aim/aim.gd
index f822182..4fdaf6c 100644
--- a/ui/components/aim/aim.gd
+++ b/ui/components/aim/aim.gd
@@ -28,7 +28,7 @@ func _process(delta: float) -> void:
return
if v.is_zero_approx():
v.x = Globals.player.sprite.scale.x # default to current facing direction
- elif Utils.is_in_range(v.y, 0.9, 1) and Util.is_in_range(v.x, -0.1, 0.1) and Globals.player.is_on_floor():
+ elif Util.is_in_range(v.y, 0.9, 1) and Util.is_in_range(v.x, -0.1, 0.1) and Globals.player.is_on_floor():
cancel_left_time -= delta
if cancel_left_time < 0:
cancel_left_time = cancel_time
diff --git a/ui/graphics.gd b/ui/graphics.gd
index b074ed5..3bec0e1 100644
--- a/ui/graphics.gd
+++ b/ui/graphics.gd
@@ -26,28 +26,10 @@ func save() -> void:
func _ready() -> void:
var lod := SaveLoad.load_file(file)
- settings = lod if dict_cmp(lod, default_settings_data) else default_settings_data # check if the keys and vaue types are correct
+ settings = lod if Util.dict_cmp(lod, default_settings_data) else default_settings_data # check if the keys and vaue types are correct
has_loaded = true
update_button_visuals()
-static func dict_cmp(d1: Dictionary, d2: Dictionary) -> bool:
- return (
- len(d1) == len(d2)
- and sort(d1.keys()) == sort(d2.keys())
- and value_types(d1.values()) == value_types(d2.values())
- )
-
-static func sort(arr: Array) -> Array:
- arr.sort()
- return arr
-
-static func value_types(arr: Array) -> Array:
- var types = []
- for value in arr:
- types.append(typeof(value))
- types.sort()
- return types
-
func update_button_visuals():
ignore_set_settings = true
vsync.button_pressed = settings.vsync
diff --git a/ui/hud/health_meter.gd b/ui/hud/health_meter.gd
index d625559..248009a 100644
--- a/ui/hud/health_meter.gd
+++ b/ui/hud/health_meter.gd
@@ -6,6 +6,7 @@ extends Control
func _ready():
Globals.player.hp_changed.connect(_hp_changed)
var max_hp := Globals.player.max_health
+ await get_tree().process_frame
full.size.x = max_hp * 5 + 1
empty.size.x = max_hp * 5 + 1