summaryrefslogtreecommitdiff
path: root/client/player
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-12-23 16:41:57 +0100
committermetamuffin <metamuffin@disroot.org>2024-12-25 20:01:20 +0100
commit469d554381597a383aa799b29261786de19fb08e (patch)
tree229303a223d786f4f725b2f41e79b59d9e3a2e13 /client/player
parentb0df9b7c27a3d6316969d7feff4d912c3abf99f6 (diff)
downloadhurrycurry-469d554381597a383aa799b29261786de19fb08e.tar
hurrycurry-469d554381597a383aa799b29261786de19fb08e.tar.bz2
hurrycurry-469d554381597a383aa799b29261786de19fb08e.tar.zst
two-handed mostly works
Diffstat (limited to 'client/player')
-rw-r--r--client/player/controllable_player.gd35
-rw-r--r--client/player/onscreen_controls/controls.gd4
-rw-r--r--client/player/player.gd54
3 files changed, 50 insertions, 43 deletions
diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd
index 9db36ad4..d241bc2e 100644
--- a/client/player/controllable_player.gd
+++ b/client/player/controllable_player.gd
@@ -83,7 +83,7 @@ func _process_movement(delta):
var boost = Input.is_action_pressed("boost") or (Global.get_setting("gameplay.latch_boost") and boosting)
- if Input.is_action_pressed("interact") or Input.is_action_just_released("interact"):
+ if Input.is_action_pressed("interact_left") or Input.is_action_just_released("interact_left") or Input.is_action_pressed("interact_right") or Input.is_action_just_released("interact_right"):
input *= 0
else:
target = Vector2i(
@@ -167,8 +167,8 @@ func aabb_point_distance(mi: Vector2, ma: Vector2, p: Vector2) -> float:
func update_position(_new_position: Vector2, _new_rotation: float, _new_boosting: bool):
pass
-func progress(position__: float, speed: float, warn: bool):
- super(position__, speed, warn)
+func progress(position__: float, speed: float, warn: bool, h):
+ super(position__, speed, warn, h)
if warn:
current_vibration_strength = position__
current_vibration_change = speed
@@ -190,14 +190,14 @@ func _on_vibration_timeout():
Input.vibrate_handheld(100, vibration_strength)
vibration_timer.start()
-func put_item(tile: Tile):
- super(tile)
+func put_item(tile: Tile, h):
+ super(tile, h)
if Global.get_setting("gameplay.vibration"):
Input.start_joy_vibration(0, 0.1, 0.0, 0.075)
Input.vibrate_handheld(75, 0.1)
-func take_item(tile: Tile):
- super(tile)
+func take_item(tile: Tile, h):
+ super(tile, h)
if Global.get_setting("gameplay.vibration"):
Input.start_joy_vibration(0, 0.1, 0.0, 0.075)
Input.vibrate_handheld(75, 0.1)
@@ -210,19 +210,20 @@ func interact():
# clear last interaction if target has moved since
if last_interaction != null and not last_interaction == target:
- game.mp.send_tile_interact(game.player_id, last_interaction, false)
+ game.mp.send_tile_interact(game.player_id, last_interaction, false, "left")
marker.set_interacting(false)
last_interaction = null
marker.set_interactive(game.get_tile_interactive(target))
marker_target = tile.item_base.global_position
- if Input.is_action_just_pressed("interact") and last_interaction == null:
- last_interaction = target
- game.mp.send_tile_interact(game.player_id, target, true)
- tile.interact()
- marker.set_interacting(true)
- if Input.is_action_just_released("interact"):
- last_interaction = null
- game.mp.send_tile_interact(game.player_id, target, false)
- marker.set_interacting(false)
+ for h in ["left", "right"]:
+ if Input.is_action_just_pressed("interact_"+h) and last_interaction == null:
+ last_interaction = target
+ game.mp.send_tile_interact(game.player_id, target, true, h)
+ tile.interact()
+ marker.set_interacting(true)
+ if Input.is_action_just_released("interact_"+h):
+ last_interaction = null
+ game.mp.send_tile_interact(game.player_id, target, false, h)
+ marker.set_interacting(false)
else:
marker.visible = false
diff --git a/client/player/onscreen_controls/controls.gd b/client/player/onscreen_controls/controls.gd
index 0d240ddb..06efb82e 100644
--- a/client/player/onscreen_controls/controls.gd
+++ b/client/player/onscreen_controls/controls.gd
@@ -42,11 +42,11 @@ func _on_boost_released():
boost.modulate = Color.WHITE
func _on_interact_pressed():
- Input.action_press("interact")
+ Input.action_press("interact_left")
interact.modulate = modulate_color
func _on_interact_released():
- Input.action_release("interact")
+ Input.action_release("interact_left")
interact.modulate = Color.WHITE
func _on_pause_pressed():
diff --git a/client/player/player.gd b/client/player/player.gd
index c314dad2..3285cafc 100644
--- a/client/player/player.gd
+++ b/client/player/player.gd
@@ -41,16 +41,17 @@ var marker_target = Vector3(0, 0, 0)
var clear_timer: Timer = Timer.new()
-var hand: Item = null
-var hand_base: Node3D = Node3D.new()
+var hand = [null, null]
+var hand_base = [Node3D.new(), Node3D.new()]
var character_idx: int
var is_customer: bool
var current_item_message = null
var _anim_angle: float = 0.0
-var hand_base_position: Vector3 = DEFAULT_HAND_BASE_POSITION
-const DEFAULT_HAND_BASE_POSITION: Vector3 = Vector3(0, .425, .4)
+var hand_base_position = [DEFAULT_HAND_BASE_POSITION_LEFT, DEFAULT_HAND_BASE_POSITION_RIGHT]
+const DEFAULT_HAND_BASE_POSITION_LEFT: Vector3 = Vector3(.3, .425, .4)
+const DEFAULT_HAND_BASE_POSITION_RIGHT: Vector3 = Vector3(-.3, .425, .4)
func _init(_id: int, new_name: String, pos: Vector2, new_character_idx: int, new_game: Game):
add_child(movement_base)
@@ -62,9 +63,12 @@ func _init(_id: int, new_name: String, pos: Vector2, new_character_idx: int, new
game = new_game
username = new_name
- hand_base.name = "HandBase"
- hand_base.position = hand_base_position
- movement_base.add_child(hand_base)
+ hand_base[0].name = "HandBaseLeft"
+ hand_base[1].name = "HandBaseRight"
+ hand_base[0].position = hand_base_position[0]
+ hand_base[1].position = hand_base_position[1]
+ movement_base.add_child(hand_base[0])
+ movement_base.add_child(hand_base[1])
movement_base.add_child(chat_bubble)
movement_base.add_child(item_bubble)
@@ -96,45 +100,47 @@ func update_username_tag(state):
tag.text = username
tag.visible = state
-func set_item(i: Item):
- if hand != null: hand.remove()
+func set_item(i: Item, h):
+ if hand[G.hand_to_index(h)] != null: hand[G.hand_to_index(h)].remove()
if i != null:
@warning_ignore("static_called_on_instance")
- hand_base_position = DEFAULT_HAND_BASE_POSITION - Vector3(0.,i.height() * 0.5, 0.)
+ hand_base_position[0] = DEFAULT_HAND_BASE_POSITION_LEFT - Vector3(0.,i.height() * 0.5, 0.)
+ @warning_ignore("static_called_on_instance")
+ hand_base_position[1] = DEFAULT_HAND_BASE_POSITION_RIGHT - Vector3(0.,i.height() * 0.5, 0.)
character.holding = i != null
- hand = i
- if hand != null: hand.owned_by = hand_base
+ hand[G.hand_to_index(h)] = i
+ if hand[G.hand_to_index(h)] != null: hand[G.hand_to_index(h)].owned_by = hand_base[G.hand_to_index(h)]
-func remove_item():
- var i = hand
+func remove_item(h):
+ var i = hand[G.hand_to_index(h)]
if i == null: push_error("holding nothing")
- hand = null
+ hand[G.hand_to_index(h)] = null
character.holding = false
return i
-func progress(position__: float, speed: float, warn: bool):
- if hand != null: hand.progress(position__, speed, warn)
+func progress(position__: float, speed: float, warn: bool, h):
+ if hand[G.hand_to_index(h)] != null: hand[G.hand_to_index(h)].progress(position__, speed, warn)
func finish():
if hand != null: hand.finish()
-func take_item(tile: Tile):
+func take_item(tile: Tile, h):
if hand != null: push_error("already holding an item")
var i = tile.take_item()
i.take()
- set_item(i)
+ set_item(i, h)
-func put_item(tile: Tile):
- var i = remove_item()
+func put_item(tile: Tile, h):
+ var i = remove_item(h)
i.put()
tile.put_item(i)
-func pass_to(player: Player):
- var i = remove_item()
+func pass_to(player: Player, hfrom, hto):
+ var i = remove_item(hfrom)
i.player_owned_timer = 0
if player.hand != null:
push_error("target is already holding an item")
- player.set_item(i)
+ player.set_item(i, hto)
func _process(delta):
_anim_angle = fmod(_anim_angle + delta, TAU)