aboutsummaryrefslogtreecommitdiff
path: root/client/scripts/player.gd
diff options
context:
space:
mode:
authornokoe <nokoe@mailbox.org>2024-06-22 18:14:27 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-23 19:28:50 +0200
commitfbb81024ea206bfad1436e27f49175a815b010b7 (patch)
tree4ec70f7862673f43f8718c47e2f60a78409c807a /client/scripts/player.gd
parent05269b84133a3a91b5234fcc47f7135eb15e4b3e (diff)
downloadhurrycurry-fbb81024ea206bfad1436e27f49175a815b010b7.tar
hurrycurry-fbb81024ea206bfad1436e27f49175a815b010b7.tar.bz2
hurrycurry-fbb81024ea206bfad1436e27f49175a815b010b7.tar.zst
update multiplayer, add take, put
Diffstat (limited to 'client/scripts/player.gd')
-rw-r--r--client/scripts/player.gd21
1 files changed, 17 insertions, 4 deletions
diff --git a/client/scripts/player.gd b/client/scripts/player.gd
index 8f53b790..6e07c3aa 100644
--- a/client/scripts/player.gd
+++ b/client/scripts/player.gd
@@ -9,7 +9,9 @@ var position_ = Vector2(0, 0)
var mesh = preload("res://scenes/player.tscn").instantiate()
-func _init(id: int, new_name: String, pos: Vector2, _character: int, new_game: Game):
+var hand: Node3D = null
+
+func _init(id: int, new_name: String, pos: Vector2, _character: int):
add_child(mesh)
position_ = pos
name = new_name
@@ -19,6 +21,17 @@ func update_position(new_position: Vector2, new_rotation: float):
position_ = new_position
rotation.y = new_rotation
-func _process(delta):
- position.x = position_.x
- position.z = position_.y
+func take_item(tile: FullTile):
+ if hand != null:
+ push_error("already holding an item")
+ var i = tile.take_item()
+ if i == null:
+ push_error("tile is null")
+ hand = i
+
+func put_item(tile: FullTile):
+ var i = hand
+ if i == null:
+ push_error("holding nothing")
+ i = null
+ tile.put_item(hand)