1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-14 21:15:58 +00:00

Merge branch 'game-logic' of https://github.com/StatewideInk/Group12 into game-logic

This commit is contained in:
tommy-l-ngo 2021-11-23 00:09:38 -06:00
commit b80288b3f4

View File

@ -36,11 +36,14 @@ sync func receive(mail):
# Sent it off to anything that expects mail # Sent it off to anything that expects mail
emit_signal("incoming", mail) emit_signal("incoming", mail)
# send: Called when sending a message
# id: Peer ID of the recipient
# mail: Variant of a json-encodable type (non-Object) to send
func send(id, mail): func send(id, mail):
# Make the recipient receive the mail # Make the recipient receive the mail
rpc_id(id, "receive", to_json(mail)) rpc_id(id, "receive", to_json(mail))
# start_server: Host the game # start_host: Host the game
# port: TCP port # port: TCP port
# max_players: Largest number of players allowed to connect at a time # max_players: Largest number of players allowed to connect at a time
func start_host(port = DEFAULT_PORT, max_players = 2): func start_host(port = DEFAULT_PORT, max_players = 2):
@ -53,13 +56,14 @@ func start_host(port = DEFAULT_PORT, max_players = 2):
hosting = true hosting = true
return return
# connect_server: Connect to a host # connect_host: Connect to a host
func connect_host(ip = LOCALHOST, port = DEFAULT_PORT): func connect_host(ip = LOCALHOST, port = DEFAULT_PORT):
get_hostname() get_hostname()
var peer = NetworkedMultiplayerENet.new() var peer = NetworkedMultiplayerENet.new()
peer.create_client(ip, port) peer.create_client(ip, port)
get_tree().network_peer = peer get_tree().network_peer = peer
# disconnect_host
func disconnect_host(): func disconnect_host():
# Set state to disconnected # Set state to disconnected
connected = false connected = false