diff options
author | tpart <tpart120@proton.me> | 2024-08-06 21:36:35 +0200 |
---|---|---|
committer | tpart <tpart120@proton.me> | 2024-08-06 21:36:35 +0200 |
commit | bb19bbc0ec5b44585a0aa377ca0beef94e38f5e4 (patch) | |
tree | 9ddd92bed4559a39c33b0564c4caf91351bb6531 /client/player/controllable_player.gd | |
parent | bd2956b13e05ad43776f9e292abac65dba49293d (diff) | |
download | hurrycurry-bb19bbc0ec5b44585a0aa377ca0beef94e38f5e4.tar hurrycurry-bb19bbc0ec5b44585a0aa377ca0beef94e38f5e4.tar.bz2 hurrycurry-bb19bbc0ec5b44585a0aa377ca0beef94e38f5e4.tar.zst |
Add pause button to touch screen controls; Fix touch controls visibility
Diffstat (limited to 'client/player/controllable_player.gd')
-rw-r--r-- | client/player/controllable_player.gd | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd index f9cb74f1..7f33831d 100644 --- a/client/player/controllable_player.gd +++ b/client/player/controllable_player.gd @@ -66,9 +66,10 @@ func _process(delta): _process_movement(dt) delta -= dt super(delta) + update_touch_scrolls() func _process_movement(delta): - var input = Input.get_vector("left", "right", "forward", "backwards") if not game.menu.covered and enable_input else Vector2.ZERO + var input = Input.get_vector("left", "right", "forward", "backwards") if is_input_enabled() else Vector2.ZERO var boost = Input.is_action_pressed("boost") or (Global.get_setting("latch_boost") and boosting) input = input.rotated( - game.camera.angle_target) if Input.is_action_pressed("interact") or Input.is_action_just_released("interact"): @@ -130,6 +131,14 @@ func collide(dt: float): self.velocity_.x += norm.x * f * dt self.velocity_.y += norm.y * f * dt +func is_input_enabled() -> bool: + return not game.menu.covered and enable_input + +func update_touch_scrolls(): + # TODO: Don't call this function every frame, but only when input menu + # covered value is updated + onscreen_controls.visible = is_input_enabled() + func aabb_point_distance(mi: Vector2, ma: Vector2, p: Vector2) -> float: return (p - p.clamp(mi, ma)).length() |