commit c5db911ec988be160ef1bddf315dd284affc4fc2
parent 4b5bbb7d9909612b291d84d289f850aaa2f1b868
Author: FIGBERT <figbert@figbert.com>
Date: Sat, 13 Feb 2021 22:02:53 -0800
Fix bug causing shake to be counted multiple times
This patch adds a half-second delay after a shake that
disables further shake detection, which prevents a number
of glitches.
For more info: 2fe587cead7387f388ff6e91cfed6bdddc3aa289
Diffstat:
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/scripts/main.gd b/src/scripts/main.gd
@@ -12,6 +12,7 @@ const PLAYER_STARTING_GELT := 10
var ACCEL_THRESHOLD := 3 if OS.get_name() == "iOS" else 30
var players := {}
var pot := POT_STARTING_GELT
+var spin_disabled := false
remotesync var game_started := false
remotesync var current_turn := { "id": -1, "index": -1 }
@@ -217,8 +218,15 @@ func _client_connection_failed() -> void:
func _check_for_spin() -> void:
var accel := Input.get_accelerometer()
- if accel.length() > ACCEL_THRESHOLD:
+ if accel.length() > ACCEL_THRESHOLD and not spin_disabled:
rpc_id(1, "shake_action")
+ _toggle_spin()
+
+
+func _toggle_spin() -> void:
+ spin_disabled = true
+ yield(get_tree().create_timer(0.5), "timeout")
+ spin_disabled = false
remote func print_message_from_server(message: String) -> void: