diff options
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() |