summaryrefslogtreecommitdiff
path: root/Levels/Level.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-07-19 14:18:21 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-07-19 14:18:21 +0200
commit7ce3593119b399196d71c88e3d1cab08ff38bb80 (patch)
treecb0abec447ee9d053836b3eefb9a3947f4a2cb6c /Levels/Level.gd
parent7e579ced0b51f98b2c14a0c868bf428c12d4790b (diff)
cleanup and begin lobby reworkHEADmain
Diffstat (limited to 'Levels/Level.gd')
-rw-r--r--Levels/Level.gd50
1 files changed, 26 insertions, 24 deletions
diff --git a/Levels/Level.gd b/Levels/Level.gd
index 40c75ff..9998a4e 100644
--- a/Levels/Level.gd
+++ b/Levels/Level.gd
@@ -19,30 +19,7 @@ func _ready():
character = load("res://Characters/" + Network.player.character + ".tscn").instantiate()
self.set_player(character)
- Network.connect("player_changed", func(id):
- var remote_player = Network.players[id]
-
- var node_name = "%s_%s_%s" % [remote_player.name, remote_player.character, id]
- var puppet = null
- if self.has_node(node_name):
- puppet = self.get_node(node_name)
-
- if remote_player.current_level != self.idx:
- if puppet:
- puppet.queue_free()
- return
-
- if not puppet:
- puppet = load("res://Characters/" + remote_player.character + ".tscn").instantiate()
- puppet.process_mode = PROCESS_MODE_DISABLED
- self.add_child(puppet)
- puppet.name = node_name
- puppet.modulate = Color(1.0, 1.0, 1.0, 0.5)
- else:
- puppet.position = remote_player.position
- puppet.get_node("Sprite2D").play(remote_player.animation)
- puppet.get_node("Sprite2D").flip_h = remote_player.animation_flip_h
- )
+ Network.connect("player_changed", Callable(self, 'update_puppet'))
if has_node("ParallaxBackground"):
$ParallaxBackground/ParallaxLayer.motion_mirroring.x = (
@@ -94,6 +71,31 @@ func respawn_player():
Global.change_scene_to_instance(instance_level)
+func update_puppet(id: int):
+ var remote_player = Network.players[id]
+
+ var node_name = "%s_%s_%s" % [remote_player.name, remote_player.character, id]
+ var puppet = null
+ if self.has_node(node_name):
+ puppet = self.get_node(node_name)
+
+ if remote_player.current_level != self.idx:
+ if puppet:
+ puppet.queue_free()
+ return
+
+ if not puppet:
+ puppet = load("res://Characters/" + remote_player.character + ".tscn").instantiate()
+ puppet.process_mode = PROCESS_MODE_DISABLED
+ self.add_child(puppet)
+ puppet.name = node_name
+ puppet.modulate = Color(1.0, 1.0, 1.0, 0.5)
+ else:
+ puppet.position = remote_player.position
+ puppet.get_node("Sprite2D").play(remote_player.animation)
+ puppet.get_node("Sprite2D").flip_h = remote_player.animation_flip_h
+
+
func end_level():
Global.end_level(self)