multiplayer

This commit is contained in:
Rendo 2025-11-22 01:07:18 +05:00
commit 0dc6247f91
22 changed files with 298 additions and 14 deletions

View file

@ -0,0 +1,28 @@
extends Node
func _ready() -> void:
multiplayer.peer_connected.connect(on_peer_connected)
multiplayer.peer_disconnected.connect(on_peer_disconnected)
Lobby.lobby_created.emit(add_self)
Lobby.lobby_joined.emit(add_self)
Lobby.lobby_closed.emit(clear)
func on_peer_connected(id: int) -> void:
var label = Label.new()
label.text = str(id)
label.name = str(id)
add_child(label,true)
func on_peer_disconnected(id: int) -> void:
get_node(str(id)).queue_free()
func add_self() -> void:
var label = Label.new()
label.text = str(multiplayer.get_unique_id())
label.name = str(multiplayer.get_unique_id())
add_child(label,true)
func clear() -> void:
for child in get_children():
child.queue_free()