godot-webrtc-mplayer-testing/scripts/screens/game.gd

27 lines
777 B
GDScript3
Raw Normal View History

2021-11-15 15:43:33 -06:00
extends Node2D
2021-12-08 16:35:37 -06:00
onready var player = preload("res://objects/player.tscn")
2021-11-15 15:43:33 -06:00
onready var camera = $camera
onready var camera_target = null
onready var zoom_levels = [0.25, 0.5, 1, 1.5, 2, 2.5, 3]
onready var current_zoom_level_index = 2
2021-11-15 15:43:33 -06:00
func _ready():
# TODO: probably have to wait for all peers to be ready before we add players
2021-12-08 16:35:37 -06:00
rpc("add_player", get_tree().get_network_unique_id())
2021-11-15 15:43:33 -06:00
2021-12-08 16:35:37 -06:00
func _process(delta):
pass
2021-11-15 15:43:33 -06:00
2021-12-08 16:35:37 -06:00
remotesync func add_player(peer_id):
var new_player = player.instance()
new_player.name = Global.negotiator.peer_by_peer_id(peer_id).name
2021-12-08 16:35:37 -06:00
new_player.set_network_master(peer_id)
add_child(new_player)
2021-12-08 23:39:56 -06:00
new_player.global_position = Vector2(100, 100)
print("Added player: %s for peer %s" % [new_player, peer_id])
2021-11-15 15:43:33 -06:00
func _on_Button_pressed():
2021-11-17 08:18:12 -06:00
Global.main_menu()