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,13 @@
extends Node
func _ready() -> void:
Lobby.lobby_joined.connect(on_lobby_joined)
func _on_leave_button_pressed() -> void:
Lobby.leave()
func _on_start_button_pressed() -> void:
Lobby.start_game.rpc()
func on_lobby_joined() -> void:
$StartButton.hide()

View file

@ -0,0 +1 @@
uid://2uyxkfmbbims

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

View file

@ -0,0 +1 @@
uid://cl3hhmw5666sj

View file

@ -0,0 +1,14 @@
extends Node
func _on_host_button_pressed() -> void:
Lobby.host()
$MainMenu.hide()
$Lobby.show()
func _on_connect_button_pressed() -> void:
Lobby.join("localhost")
$MainMenu.hide()
$Lobby.show()

View file

@ -0,0 +1 @@
uid://bsyuos803g7qf