multiplayer
This commit is contained in:
parent
aa35ee5975
commit
0dc6247f91
22 changed files with 298 additions and 14 deletions
29
scripts/multiplayer/lobby.gd
Normal file
29
scripts/multiplayer/lobby.gd
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
extends Node
|
||||
|
||||
|
||||
const MAX_PLAYERS: int = 10
|
||||
const PORT: int = 7777
|
||||
|
||||
signal lobby_created
|
||||
signal lobby_joined
|
||||
signal lobby_closed
|
||||
|
||||
func host() -> void:
|
||||
var peer: ENetMultiplayerPeer = ENetMultiplayerPeer.new()
|
||||
peer.create_server(PORT,MAX_PLAYERS)
|
||||
multiplayer.multiplayer_peer = peer
|
||||
lobby_created.emit()
|
||||
|
||||
func join(ip: String) -> void:
|
||||
var peer: ENetMultiplayerPeer = ENetMultiplayerPeer.new()
|
||||
peer.create_client(ip,PORT)
|
||||
multiplayer.multiplayer_peer = peer
|
||||
lobby_joined.emit()
|
||||
|
||||
func leave() -> void:
|
||||
multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()
|
||||
lobby_closed.emit()
|
||||
|
||||
@rpc("authority","call_local","reliable")
|
||||
func start_game() -> void:
|
||||
get_tree().change_scene_to_file("res://levels/prototype_scene.tscn")
|
||||
Loading…
Add table
Add a link
Reference in a new issue