mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 23:10:08 +01:00
Convert demos to Godot 4 using regular expressions in a script
This commit is contained in:
@@ -1,32 +1,32 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://bomb.gd" type="Script" id=1]
|
||||
[ext_resource path="res://brickfloor.png" type="Texture" id=2]
|
||||
[ext_resource path="res://explosion.png" type="Texture" id=3]
|
||||
[ext_resource path="res://brickfloor.png" type="Texture2D" id=2]
|
||||
[ext_resource path="res://explosion.png" type="Texture2D" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 8, 96 )
|
||||
extents = Vector2(8, 96)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 96, 8 )
|
||||
extents = Vector2(96, 8)
|
||||
|
||||
[sub_resource type="Curve" id=3]
|
||||
max_value = 2.0
|
||||
_data = [ Vector2( 0.00150494, 0.398437 ), 0.0, 0.0, 0, 0, Vector2( 0.0152287, 1.42969 ), 0.0, 0.0, 0, 0, Vector2( 0.478607, 1.30078 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.291016 ), 0.0, 0.0, 0, 0 ]
|
||||
_data = [Vector2(0.00150494, 0.398437), 0.0, 0.0, 0, 0, Vector2(0.0152287, 1.42969), 0.0, 0.0, 0, 0, Vector2(0.478607, 1.30078), 0.0, 0.0, 0, 0, Vector2(1, 0.291016), 0.0, 0.0, 0, 0]
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
length = 4.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:self_modulate")
|
||||
tracks/0/path = NodePath("Sprite2D:self_modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.4, 0.6, 0.8, 1.1, 1.3, 1.5, 1.8, 1.9, 2, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 3 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.4, 0.6, 0.8, 1.1, 1.3, 1.5, 1.8, 1.9, 2, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 3),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 8, 8, 8, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 8, 8, 8, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 8, 8, 8, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 8, 8, 8, 1 ), Color( 1, 1, 1, 1 ), Color( 8, 8, 8, 1 ), Color( 1, 1, 1, 1 ), Color( 8, 8, 8, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(8, 8, 8, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
tracks/1/type = "method"
|
||||
tracks/1/path = NodePath(".")
|
||||
@@ -35,15 +35,15 @@ tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 2.8, 3.4 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"times": PackedFloat32Array(2.8, 3.4),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": "explode"
|
||||
}, {
|
||||
"args": [ ],
|
||||
"args": [],
|
||||
"method": "done"
|
||||
} ]
|
||||
}]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("Explosion1:emitting")
|
||||
@@ -52,10 +52,10 @@ tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0, 2.8 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 2.8),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [ false, true ]
|
||||
"values": [false, true]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath("Explosion2:emitting")
|
||||
@@ -64,20 +64,20 @@ tracks/3/loop_wrap = true
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/keys = {
|
||||
"times": PoolRealArray( 0, 2.8 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 2.8),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [ false, true ]
|
||||
"values": [false, true]
|
||||
}
|
||||
|
||||
[node name="Bomb" type="Area2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( -2.92606, -2.92606 )
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(-2.92606, -2.92606)
|
||||
texture = ExtResource( 2 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 144, 0, 48, 48 )
|
||||
region_rect = Rect2(144, 0, 48, 48)
|
||||
|
||||
[node name="Shape1" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
@@ -92,8 +92,8 @@ one_shot = true
|
||||
explosiveness = 0.95
|
||||
texture = ExtResource( 3 )
|
||||
emission_shape = 2
|
||||
emission_rect_extents = Vector2( 80, 1 )
|
||||
gravity = Vector2( 0, 0 )
|
||||
emission_rect_extents = Vector2(80, 1)
|
||||
gravity = Vector2(0, 0)
|
||||
initial_velocity = 1.0
|
||||
angular_velocity = 187.85
|
||||
angular_velocity_random = 1.0
|
||||
@@ -101,14 +101,14 @@ scale_amount_curve = SubResource( 3 )
|
||||
|
||||
[node name="Explosion2" type="CPUParticles2D" parent="."]
|
||||
rotation = 1.57162
|
||||
scale = Vector2( 1, 1 )
|
||||
scale = Vector2(1, 1)
|
||||
emitting = false
|
||||
one_shot = true
|
||||
explosiveness = 0.95
|
||||
texture = ExtResource( 3 )
|
||||
emission_shape = 2
|
||||
emission_rect_extents = Vector2( 80, 1 )
|
||||
gravity = Vector2( 0, 0 )
|
||||
emission_rect_extents = Vector2(80, 1)
|
||||
gravity = Vector2(0, 0)
|
||||
initial_velocity = 1.0
|
||||
angular_velocity = 187.85
|
||||
angular_velocity_random = 1.0
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/brickfloor.png-bab1cbace80ab627972eea565951db9e.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/brickfloor.png-bab1cbace80ab627972eea565951db9e.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://brickfloor.png"
|
||||
dest_files=[ "res://.import/brickfloor.png-bab1cbace80ab627972eea565951db9e.stex" ]
|
||||
dest_files=["res://.godot/imported/brickfloor.png-bab1cbace80ab627972eea565951db9e.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/charwalk.png-a9f067962a6454cc2f52a6e82832cbc5.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/charwalk.png-a9f067962a6454cc2f52a6e82832cbc5.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://charwalk.png"
|
||||
dest_files=[ "res://.import/charwalk.png-a9f067962a6454cc2f52a6e82832cbc5.stex" ]
|
||||
dest_files=["res://.godot/imported/charwalk.png-a9f067962a6454cc2f52a6e82832cbc5.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/explosion.png-730076d88b39dbfd5c22ad71f1135b01.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/explosion.png-730076d88b39dbfd5c22ad71f1135b01.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://explosion.png"
|
||||
dest_files=[ "res://.import/explosion.png-730076d88b39dbfd5c22ad71f1135b01.stex" ]
|
||||
dest_files=["res://.godot/imported/explosion.png-730076d88b39dbfd5c22ad71f1135b01.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func _player_connected(id):
|
||||
|
||||
# Callback from SceneTree.
|
||||
func _player_disconnected(id):
|
||||
if has_node("/root/World"): # Game is in progress.
|
||||
if has_node("/root/World3D"): # Game is in progress.
|
||||
if get_tree().is_network_server():
|
||||
emit_signal("game_error", "Player " + players[id] + " disconnected")
|
||||
end_game()
|
||||
@@ -75,16 +75,16 @@ func unregister_player(id):
|
||||
|
||||
remote func pre_start_game(spawn_points):
|
||||
# Change scene.
|
||||
var world = load("res://world.tscn").instance()
|
||||
var world = load("res://world.tscn").instantiate()
|
||||
get_tree().get_root().add_child(world)
|
||||
|
||||
get_tree().get_root().get_node("Lobby").hide()
|
||||
get_tree().get_root().get_node(^"Lobby").hide()
|
||||
|
||||
var player_scene = load("res://player.tscn")
|
||||
|
||||
for p_id in spawn_points:
|
||||
var spawn_pos = world.get_node("SpawnPoints/" + str(spawn_points[p_id])).position
|
||||
var player = player_scene.instance()
|
||||
var spawn_pos = world.get_node(^"SpawnPoints/" + str(spawn_points[p_id])).position
|
||||
var player = player_scene.instantiate()
|
||||
|
||||
player.set_name(str(p_id)) # Use unique ID as node name.
|
||||
player.position=spawn_pos
|
||||
@@ -97,12 +97,12 @@ remote func pre_start_game(spawn_points):
|
||||
# Otherwise set name from peer.
|
||||
player.set_player_name(players[p_id])
|
||||
|
||||
world.get_node("Players").add_child(player)
|
||||
world.get_node(^"Players").add_child(player)
|
||||
|
||||
# Set up score.
|
||||
world.get_node("Score").add_player(get_tree().get_network_unique_id(), player_name)
|
||||
world.get_node(^"Score").add_player(get_tree().get_network_unique_id(), player_name)
|
||||
for pn in players:
|
||||
world.get_node("Score").add_player(pn, players[pn])
|
||||
world.get_node(^"Score").add_player(pn, players[pn])
|
||||
|
||||
if not get_tree().is_network_server():
|
||||
# Tell server we are ready to start.
|
||||
@@ -167,17 +167,17 @@ func begin_game():
|
||||
|
||||
|
||||
func end_game():
|
||||
if has_node("/root/World"): # Game is in progress.
|
||||
if has_node("/root/World3D"): # Game is in progress.
|
||||
# End it
|
||||
get_node("/root/World").queue_free()
|
||||
get_node(^"/root/World3D").queue_free()
|
||||
|
||||
emit_signal("game_ended")
|
||||
players.clear()
|
||||
|
||||
|
||||
func _ready():
|
||||
get_tree().connect("network_peer_connected", self, "_player_connected")
|
||||
get_tree().connect(&"network_peer_connected", self._player_connected)
|
||||
get_tree().connect("network_peer_disconnected", self,"_player_disconnected")
|
||||
get_tree().connect("connected_to_server", self, "_connected_ok")
|
||||
get_tree().connect("connection_failed", self, "_connected_fail")
|
||||
get_tree().connect("server_disconnected", self, "_server_disconnected")
|
||||
get_tree().connect(&"connected_to_server", self._connected_ok)
|
||||
get_tree().connect(&"connection_failed", self._connected_fail)
|
||||
get_tree().connect(&"server_disconnected", self._server_disconnected)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ extends Control
|
||||
|
||||
func _ready():
|
||||
# Called every time the node is added to the scene.
|
||||
gamestate.connect("connection_failed", self, "_on_connection_failed")
|
||||
gamestate.connect("connection_succeeded", self, "_on_connection_success")
|
||||
gamestate.connect("player_list_changed", self, "refresh_lobby")
|
||||
gamestate.connect("game_ended", self, "_on_game_ended")
|
||||
gamestate.connect("game_error", self, "_on_game_error")
|
||||
gamestate.connect(&"connection_failed", self._on_connection_failed)
|
||||
gamestate.connect(&"connection_succeeded", self._on_connection_success)
|
||||
gamestate.connect(&"player_list_changed", self.refresh_lobby)
|
||||
gamestate.connect(&"game_ended", self._on_game_ended)
|
||||
gamestate.connect(&"game_error", self._on_game_error)
|
||||
# Set the player name according to the system username. Fallback to the path.
|
||||
if OS.has_environment("USERNAME"):
|
||||
$Connect/Name.text = OS.get_environment("USERNAME")
|
||||
@@ -68,7 +68,7 @@ func _on_game_ended():
|
||||
|
||||
func _on_game_error(errtxt):
|
||||
$ErrorDialog.dialog_text = errtxt
|
||||
$ErrorDialog.popup_centered_minsize()
|
||||
$ErrorDialog.popup_centered_clamped()
|
||||
$Connect/Host.disabled = false
|
||||
$Connect/Join.disabled = false
|
||||
|
||||
|
||||
@@ -18,44 +18,44 @@ anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -126.0
|
||||
margin_top = -177.5
|
||||
margin_right = 126.0
|
||||
margin_bottom = 177.5
|
||||
offset_left = -126.0
|
||||
offset_top = -177.5
|
||||
offset_right = 126.0
|
||||
offset_bottom = 177.5
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Players"]
|
||||
margin_left = 26.0
|
||||
margin_top = 18.0
|
||||
margin_right = 142.0
|
||||
margin_bottom = 32.0
|
||||
offset_left = 26.0
|
||||
offset_top = 18.0
|
||||
offset_right = 142.0
|
||||
offset_bottom = 32.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "Awaiting Players..."
|
||||
|
||||
[node name="Start" type="Button" parent="Players"]
|
||||
margin_left = 68.0
|
||||
margin_top = 307.0
|
||||
margin_right = 193.0
|
||||
margin_bottom = 336.0
|
||||
offset_left = 68.0
|
||||
offset_top = 307.0
|
||||
offset_right = 193.0
|
||||
offset_bottom = 336.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
text = "START!"
|
||||
|
||||
[node name="List" type="ItemList" parent="Players"]
|
||||
margin_left = 25.0
|
||||
margin_top = 37.0
|
||||
margin_right = 229.0
|
||||
margin_bottom = 296.0
|
||||
offset_left = 25.0
|
||||
offset_top = 37.0
|
||||
offset_right = 229.0
|
||||
offset_bottom = 296.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
|
||||
[node name="PortForward" type="Label" parent="Players"]
|
||||
margin_left = -124.0
|
||||
margin_top = 375.0
|
||||
margin_right = 128.0
|
||||
margin_bottom = 429.0
|
||||
offset_left = -124.0
|
||||
offset_top = 375.0
|
||||
offset_right = 128.0
|
||||
offset_bottom = 429.0
|
||||
custom_constants/line_spacing = 6
|
||||
text = "If you want non-LAN clients to connect,
|
||||
make sure the port 10567 in UDP
|
||||
@@ -63,10 +63,10 @@ is forwarded on your router."
|
||||
align = 1
|
||||
|
||||
[node name="FindPublicIP" type="LinkButton" parent="Players"]
|
||||
margin_left = 168.0
|
||||
margin_top = 393.5
|
||||
margin_right = 341.0
|
||||
margin_bottom = 407.5
|
||||
offset_left = 168.0
|
||||
offset_top = 393.5
|
||||
offset_right = 341.0
|
||||
offset_bottom = 407.5
|
||||
text = "Find your public IP address"
|
||||
|
||||
[node name="Connect" type="Panel" parent="."]
|
||||
@@ -74,80 +74,80 @@ anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -138.5
|
||||
margin_top = -83.5
|
||||
margin_right = 138.5
|
||||
margin_bottom = 83.5
|
||||
offset_left = -138.5
|
||||
offset_top = -83.5
|
||||
offset_right = 138.5
|
||||
offset_bottom = 83.5
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
|
||||
[node name="NameLabel" type="Label" parent="Connect"]
|
||||
margin_left = 14.0
|
||||
margin_top = 11.0
|
||||
margin_right = 56.0
|
||||
margin_bottom = 25.0
|
||||
offset_left = 14.0
|
||||
offset_top = 11.0
|
||||
offset_right = 56.0
|
||||
offset_bottom = 25.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "Name:"
|
||||
|
||||
[node name="Name" type="LineEdit" parent="Connect"]
|
||||
margin_left = 17.0
|
||||
margin_top = 30.0
|
||||
margin_right = 173.0
|
||||
margin_bottom = 54.0
|
||||
offset_left = 17.0
|
||||
offset_top = 30.0
|
||||
offset_right = 173.0
|
||||
offset_bottom = 54.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
text = "The Warrior"
|
||||
|
||||
[node name="IPLabel" type="Label" parent="Connect"]
|
||||
margin_left = 15.0
|
||||
margin_top = 66.0
|
||||
margin_right = 57.0
|
||||
margin_bottom = 80.0
|
||||
offset_left = 15.0
|
||||
offset_top = 66.0
|
||||
offset_right = 57.0
|
||||
offset_bottom = 80.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "IP:"
|
||||
|
||||
[node name="IPAddress" type="LineEdit" parent="Connect"]
|
||||
margin_left = 17.0
|
||||
margin_top = 85.0
|
||||
margin_right = 173.0
|
||||
margin_bottom = 109.0
|
||||
offset_left = 17.0
|
||||
offset_top = 85.0
|
||||
offset_right = 173.0
|
||||
offset_bottom = 109.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
text = "127.0.0.1"
|
||||
|
||||
[node name="Host" type="Button" parent="Connect"]
|
||||
margin_left = 181.0
|
||||
margin_top = 31.0
|
||||
margin_right = 246.0
|
||||
margin_bottom = 51.0
|
||||
offset_left = 181.0
|
||||
offset_top = 31.0
|
||||
offset_right = 246.0
|
||||
offset_bottom = 51.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
text = "Host"
|
||||
|
||||
[node name="Join" type="Button" parent="Connect"]
|
||||
margin_left = 181.0
|
||||
margin_top = 87.0
|
||||
margin_right = 246.0
|
||||
margin_bottom = 107.0
|
||||
offset_left = 181.0
|
||||
offset_top = 87.0
|
||||
offset_right = 246.0
|
||||
offset_bottom = 107.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
text = "Join"
|
||||
|
||||
[node name="ErrorLabel" type="Label" parent="Connect"]
|
||||
margin_left = 15.0
|
||||
margin_top = 125.0
|
||||
margin_right = 257.0
|
||||
margin_bottom = 139.0
|
||||
offset_left = 15.0
|
||||
offset_top = 125.0
|
||||
offset_right = 257.0
|
||||
offset_bottom = 139.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
custom_colors/font_color = Color( 0.820312, 0.291595, 0.291595, 1 )
|
||||
custom_colors/font_color = Color(0.820312, 0.291595, 0.291595, 1)
|
||||
align = 1
|
||||
|
||||
[node name="ErrorDialog" type="AcceptDialog" parent="."]
|
||||
margin_right = 55.0
|
||||
margin_bottom = 58.0
|
||||
offset_right = 55.0
|
||||
offset_bottom = 58.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
extends KinematicBody2D
|
||||
extends CharacterBody2D
|
||||
|
||||
const MOTION_SPEED = 90.0
|
||||
|
||||
puppet var puppet_pos = Vector2()
|
||||
puppet var puppet_motion = Vector2()
|
||||
|
||||
export var stunned = false
|
||||
@export var stunned = false
|
||||
|
||||
# Use sync because it will be called everywhere
|
||||
remotesync func setup_bomb(bomb_name, pos, by_who):
|
||||
var bomb = preload("res://bomb.tscn").instance()
|
||||
var bomb = preload("res://bomb.tscn").instantiate()
|
||||
bomb.set_name(bomb_name) # Ensure unique name for the bomb
|
||||
bomb.position = pos
|
||||
bomb.from_player = by_who
|
||||
# No need to set network master to bomb, will be owned by server by default
|
||||
get_node("../..").add_child(bomb)
|
||||
get_node(^"../..").add_child(bomb)
|
||||
|
||||
var current_anim = ""
|
||||
var prev_bombing = false
|
||||
@@ -68,8 +68,9 @@ func _physics_process(_delta):
|
||||
|
||||
if new_anim != current_anim:
|
||||
current_anim = new_anim
|
||||
get_node("anim").play(current_anim)
|
||||
get_node(^"anim").play(current_anim)
|
||||
|
||||
# TODO: This information should be set to the CharacterBody properties instead of arguments.
|
||||
# FIXME: Use move_and_slide
|
||||
move_and_slide(motion * MOTION_SPEED)
|
||||
if not is_network_master():
|
||||
@@ -88,7 +89,7 @@ master func exploded(_by_who):
|
||||
|
||||
|
||||
func set_player_name(new_name):
|
||||
get_node("label").set_text(new_name)
|
||||
get_node(^"label").set_text(new_name)
|
||||
|
||||
|
||||
func _ready():
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://charwalk.png" type="Texture" id=2]
|
||||
[ext_resource path="res://montserrat.otf" type="DynamicFontData" id=3]
|
||||
[ext_resource path="res://charwalk.png" type="Texture2D" id=2]
|
||||
[ext_resource path="res://montserrat.otf" type="FontData" id=3]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 20.0
|
||||
@@ -18,10 +18,10 @@ tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [ 0, 4, 8, 12 ]
|
||||
"values": [0, 4, 8, 12]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
@@ -34,10 +34,10 @@ tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ 0 ]
|
||||
"values": [0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("sprite:rotation_degrees")
|
||||
@@ -46,10 +46,10 @@ tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 1, 1.1 ),
|
||||
"transitions": PoolRealArray( 1, 0, 1 ),
|
||||
"times": PackedFloat32Array(0, 1, 1.1),
|
||||
"transitions": PackedFloat32Array(1, 0, 1),
|
||||
"update": 0,
|
||||
"values": [ 0.0, 720.0, 0.0 ]
|
||||
"values": [0.0, 720.0, 0.0]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath(".:stunned")
|
||||
@@ -58,10 +58,10 @@ tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 1 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(1),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
@@ -74,10 +74,10 @@ tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [ 0, 4, 8, 12 ]
|
||||
"values": [0, 4, 8, 12]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
@@ -91,10 +91,10 @@ tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [ 1, 5, 9, 13 ]
|
||||
"values": [1, 5, 9, 13]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=6]
|
||||
@@ -108,10 +108,10 @@ tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [ 3, 7, 11, 15 ]
|
||||
"values": [3, 7, 11, 15]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=7]
|
||||
@@ -125,23 +125,23 @@ tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [ 2, 6, 10, 14 ]
|
||||
"values": [2, 6, 10, 14]
|
||||
}
|
||||
|
||||
[sub_resource type="DynamicFont" id=8]
|
||||
[sub_resource type="Font" id=8]
|
||||
size = 14
|
||||
font_data = ExtResource( 3 )
|
||||
|
||||
[node name="player" type="KinematicBody2D"]
|
||||
[node name="player" type="CharacterBody2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.0750351, 6.23615 )
|
||||
[node name="sprite" type="Sprite2D" parent="."]
|
||||
position = Vector2(0.0750351, 6.23615)
|
||||
texture = ExtResource( 2 )
|
||||
offset = Vector2( -0.0750351, -6.23615 )
|
||||
offset = Vector2(-0.0750351, -6.23615)
|
||||
hframes = 4
|
||||
vframes = 4
|
||||
|
||||
@@ -157,10 +157,10 @@ anims/walk_right = SubResource( 6 )
|
||||
anims/walk_up = SubResource( 7 )
|
||||
|
||||
[node name="label" type="Label" parent="."]
|
||||
margin_left = -82.0
|
||||
margin_top = -35.0
|
||||
margin_right = 85.0
|
||||
margin_bottom = -14.0
|
||||
offset_left = -82.0
|
||||
offset_top = -35.0
|
||||
offset_right = 85.0
|
||||
offset_bottom = -14.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
custom_fonts/font = SubResource( 8 )
|
||||
|
||||
@@ -34,7 +34,7 @@ window/stretch/aspect="expand"
|
||||
|
||||
[gdnative]
|
||||
|
||||
singletons=[ ]
|
||||
singletons=[]
|
||||
|
||||
[image_loader]
|
||||
|
||||
@@ -45,43 +45,43 @@ gen_mipmaps=false
|
||||
|
||||
move_down={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777234,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
]
|
||||
}
|
||||
move_left={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
]
|
||||
}
|
||||
move_right={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777233,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
]
|
||||
}
|
||||
move_up={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
]
|
||||
}
|
||||
set_bomb={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
extends KinematicBody2D
|
||||
extends CharacterBody2D
|
||||
|
||||
# Sent to everyone else
|
||||
puppet func do_explosion():
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://rock.gd" type="Script" id=1]
|
||||
[ext_resource path="res://brickfloor.png" type="Texture" id=2]
|
||||
[ext_resource path="res://brickfloor.png" type="Texture2D" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 24, 24 )
|
||||
extents = Vector2(24, 24)
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "explode"
|
||||
@@ -15,35 +15,35 @@ tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 1 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"times": PackedFloat32Array(1),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": "queue_free"
|
||||
} ]
|
||||
}]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:visible")
|
||||
tracks/1/path = NodePath("Sprite2D:visible")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[node name="Rock" type="KinematicBody2D"]
|
||||
[node name="Rock" type="CharacterBody2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 96, 0, 48, 48 )
|
||||
region_rect = Rect2(96, 0, 48, 48)
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="."]
|
||||
[node name="Shape3D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/rock_bit.png-cd30ec3dce7edf848ee632b29d4d0c95.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/rock_bit.png-cd30ec3dce7edf848ee632b29d4d0c95.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://rock_bit.png"
|
||||
dest_files=[ "res://.import/rock_bit.png-cd30ec3dce7edf848ee632b29d4d0c95.stex" ]
|
||||
dest_files=["res://.godot/imported/rock_bit.png-cd30ec3dce7edf848ee632b29d4d0c95.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func add_player(id, new_player_name):
|
||||
l.set_align(Label.ALIGN_CENTER)
|
||||
l.set_text(new_player_name + "\n" + "0")
|
||||
l.set_h_size_flags(SIZE_EXPAND_FILL)
|
||||
var font = DynamicFont.new()
|
||||
var font = Font.new()
|
||||
font.set_size(18)
|
||||
font.set_font_data(preload("res://montserrat.otf"))
|
||||
l.add_font_override("font", font)
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://brickfloor.png" type="Texture" id=1]
|
||||
[ext_resource path="res://brickfloor.png" type="Texture2D" id=1]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 24, 24 )
|
||||
extents = Vector2(24, 24)
|
||||
|
||||
[node name="TileScene" type="Node2D"]
|
||||
|
||||
[node name="Wall" type="Sprite" parent="."]
|
||||
position = Vector2( 24, 24 )
|
||||
[node name="Wall" type="Sprite2D" parent="."]
|
||||
position = Vector2(24, 24)
|
||||
texture = ExtResource( 1 )
|
||||
region_rect = Rect2( 0, 0, 48, 48 )
|
||||
region_rect = Rect2(0, 0, 48, 48)
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="Wall"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Wall/StaticBody2D"]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Floor" type="Sprite" parent="."]
|
||||
position = Vector2( 72, 24 )
|
||||
[node name="Floor" type="Sprite2D" parent="."]
|
||||
position = Vector2(72, 24)
|
||||
texture = ExtResource( 1 )
|
||||
region_rect = Rect2( 48, 0, 48, 48 )
|
||||
region_rect = Rect2(48, 0, 48, 48)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_resource type="TileSet" load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://brickfloor.png" type="Texture" id=1]
|
||||
[ext_resource path="res://brickfloor.png" type="Texture2D" id=1]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 24, 24 )
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://ball.png"
|
||||
dest_files=[ "res://.import/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex" ]
|
||||
dest_files=["res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://logic/ball.gd" type="Script" id=1]
|
||||
[ext_resource path="res://ball.png" type="Texture" id=2]
|
||||
[ext_resource path="res://ball.png" type="Texture2D" id=2]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 5.11969
|
||||
@@ -9,8 +9,8 @@ radius = 5.11969
|
||||
[node name="Ball" type="Area2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="."]
|
||||
[node name="Shape3D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -320.0
|
||||
margin_top = -200.0
|
||||
margin_right = 320.0
|
||||
margin_bottom = 200.0
|
||||
offset_left = -320.0
|
||||
offset_top = -200.0
|
||||
offset_right = 320.0
|
||||
offset_bottom = 200.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
__meta__ = {
|
||||
@@ -18,10 +18,10 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="Title" type="Label" parent="."]
|
||||
margin_left = 210.0
|
||||
margin_top = 40.0
|
||||
margin_right = 430.0
|
||||
margin_bottom = 80.0
|
||||
offset_left = 210.0
|
||||
offset_top = 40.0
|
||||
offset_right = 430.0
|
||||
offset_bottom = 80.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "Multiplayer Pong"
|
||||
@@ -29,76 +29,76 @@ align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="LobbyPanel" type="Panel" parent="."]
|
||||
margin_left = 210.0
|
||||
margin_top = 160.0
|
||||
margin_right = 430.0
|
||||
margin_bottom = 270.0
|
||||
offset_left = 210.0
|
||||
offset_top = 160.0
|
||||
offset_right = 430.0
|
||||
offset_bottom = 270.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="AddressLabel" type="Label" parent="LobbyPanel"]
|
||||
margin_left = 10.0
|
||||
margin_top = 10.0
|
||||
margin_right = 62.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 10.0
|
||||
offset_top = 10.0
|
||||
offset_right = 62.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "Address"
|
||||
|
||||
[node name="Address" type="LineEdit" parent="LobbyPanel"]
|
||||
margin_left = 10.0
|
||||
margin_top = 30.0
|
||||
margin_right = 210.0
|
||||
margin_bottom = 54.0
|
||||
offset_left = 10.0
|
||||
offset_top = 30.0
|
||||
offset_right = 210.0
|
||||
offset_bottom = 54.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
text = "127.0.0.1"
|
||||
|
||||
[node name="HostButton" type="Button" parent="LobbyPanel"]
|
||||
margin_left = 10.0
|
||||
margin_top = 60.0
|
||||
margin_right = 90.0
|
||||
margin_bottom = 80.0
|
||||
offset_left = 10.0
|
||||
offset_top = 60.0
|
||||
offset_right = 90.0
|
||||
offset_bottom = 80.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
text = "Host"
|
||||
|
||||
[node name="JoinButton" type="Button" parent="LobbyPanel"]
|
||||
margin_left = 130.0
|
||||
margin_top = 60.0
|
||||
margin_right = 210.0
|
||||
margin_bottom = 80.0
|
||||
offset_left = 130.0
|
||||
offset_top = 60.0
|
||||
offset_right = 210.0
|
||||
offset_bottom = 80.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
text = "Join"
|
||||
|
||||
[node name="StatusOk" type="Label" parent="LobbyPanel"]
|
||||
margin_left = 10.0
|
||||
margin_top = 90.0
|
||||
margin_right = 210.0
|
||||
margin_bottom = 104.0
|
||||
offset_left = 10.0
|
||||
offset_top = 90.0
|
||||
offset_right = 210.0
|
||||
offset_bottom = 104.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
custom_colors/font_color = Color( 0, 1, 0.015625, 1 )
|
||||
custom_colors/font_color = Color(0, 1, 0.015625, 1)
|
||||
align = 1
|
||||
|
||||
[node name="StatusFail" type="Label" parent="LobbyPanel"]
|
||||
margin_left = 10.0
|
||||
margin_top = 90.0
|
||||
margin_right = 210.0
|
||||
margin_bottom = 104.0
|
||||
offset_left = 10.0
|
||||
offset_top = 90.0
|
||||
offset_right = 210.0
|
||||
offset_bottom = 104.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
custom_colors/font_color = Color( 1, 0, 0, 1 )
|
||||
custom_colors/font_color = Color(1, 0, 0, 1)
|
||||
align = 1
|
||||
|
||||
[node name="PortForward" type="Label" parent="LobbyPanel"]
|
||||
visible = false
|
||||
margin_left = -128.0
|
||||
margin_top = 136.0
|
||||
margin_right = 124.0
|
||||
margin_bottom = 184.0
|
||||
offset_left = -128.0
|
||||
offset_top = 136.0
|
||||
offset_right = 124.0
|
||||
offset_bottom = 184.0
|
||||
custom_constants/line_spacing = 6
|
||||
text = "If you want non-LAN clients to connect,
|
||||
make sure the port 8910 in UDP
|
||||
@@ -110,10 +110,10 @@ __meta__ = {
|
||||
|
||||
[node name="FindPublicIP" type="LinkButton" parent="LobbyPanel"]
|
||||
visible = false
|
||||
margin_left = 155.0
|
||||
margin_top = 152.0
|
||||
margin_right = 328.0
|
||||
margin_bottom = 166.0
|
||||
offset_left = 155.0
|
||||
offset_top = 152.0
|
||||
offset_right = 328.0
|
||||
offset_bottom = 166.0
|
||||
text = "Find your public IP address"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
|
||||
@@ -6,7 +6,7 @@ var direction = Vector2.LEFT
|
||||
var stopped = false
|
||||
var _speed = DEFAULT_SPEED
|
||||
|
||||
onready var _screen_size = get_viewport_rect().size
|
||||
@onready var _screen_size = get_viewport_rect().size
|
||||
|
||||
func _process(delta):
|
||||
_speed += delta
|
||||
|
||||
@@ -5,32 +5,32 @@ extends Control
|
||||
# https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
|
||||
const DEFAULT_PORT = 8910
|
||||
|
||||
onready var address = $Address
|
||||
onready var host_button = $HostButton
|
||||
onready var join_button = $JoinButton
|
||||
onready var status_ok = $StatusOk
|
||||
onready var status_fail = $StatusFail
|
||||
onready var port_forward_label = $PortForward
|
||||
onready var find_public_ip_button = $FindPublicIP
|
||||
@onready var address = $Address
|
||||
@onready var host_button = $HostButton
|
||||
@onready var join_button = $JoinButton
|
||||
@onready var status_ok = $StatusOk
|
||||
@onready var status_fail = $StatusFail
|
||||
@onready var port_forward_label = $PortForward
|
||||
@onready var find_public_ip_button = $FindPublicIP
|
||||
|
||||
var peer = null
|
||||
|
||||
func _ready():
|
||||
# Connect all the callbacks related to networking.
|
||||
get_tree().connect("network_peer_connected", self, "_player_connected")
|
||||
get_tree().connect("network_peer_disconnected", self, "_player_disconnected")
|
||||
get_tree().connect("connected_to_server", self, "_connected_ok")
|
||||
get_tree().connect("connection_failed", self, "_connected_fail")
|
||||
get_tree().connect("server_disconnected", self, "_server_disconnected")
|
||||
get_tree().connect(&"network_peer_connected", self._player_connected)
|
||||
get_tree().connect(&"network_peer_disconnected", self._player_disconnected)
|
||||
get_tree().connect(&"connected_to_server", self._connected_ok)
|
||||
get_tree().connect(&"connection_failed", self._connected_fail)
|
||||
get_tree().connect(&"server_disconnected", self._server_disconnected)
|
||||
|
||||
#### Network callbacks from SceneTree ####
|
||||
|
||||
# Callback from SceneTree.
|
||||
func _player_connected(_id):
|
||||
# Someone connected, start the game!
|
||||
var pong = load("res://pong.tscn").instance()
|
||||
var pong = load("res://pong.tscn").instantiate()
|
||||
# Connect deferred so we can safely erase it from the callback.
|
||||
pong.connect("game_finished", self, "_end_game", [], CONNECT_DEFERRED)
|
||||
pong.connect(&"game_finished", self._end_game, [], CONNECT_DEFERRED)
|
||||
|
||||
get_tree().get_root().add_child(pong)
|
||||
hide()
|
||||
@@ -66,7 +66,7 @@ func _end_game(with_error = ""):
|
||||
if has_node("/root/Pong"):
|
||||
# Erase immediately, otherwise network might show
|
||||
# errors (this is why we connected deferred above).
|
||||
get_node("/root/Pong").free()
|
||||
get_node(^"/root/Pong").free()
|
||||
show()
|
||||
|
||||
get_tree().set_network_peer(null) # Remove peer.
|
||||
|
||||
@@ -2,17 +2,17 @@ extends Area2D
|
||||
|
||||
const MOTION_SPEED = 150
|
||||
|
||||
export var left = false
|
||||
@export var left = false
|
||||
|
||||
var _motion = 0
|
||||
var _you_hidden = false
|
||||
|
||||
onready var _screen_size_y = get_viewport_rect().size.y
|
||||
@onready var _screen_size_y = get_viewport_rect().size.y
|
||||
|
||||
func _process(delta):
|
||||
# Is the master of the paddle.
|
||||
if is_network_master():
|
||||
_motion = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
||||
_motion = Input.get_axis(&"move_up", &"move_down")
|
||||
|
||||
if not _you_hidden and _motion != 0:
|
||||
_hide_you_label()
|
||||
@@ -40,7 +40,7 @@ puppet func set_pos_and_motion(pos, motion):
|
||||
|
||||
func _hide_you_label():
|
||||
_you_hidden = true
|
||||
get_node("You").hide()
|
||||
get_node(^"You").hide()
|
||||
|
||||
|
||||
func _on_paddle_area_enter(area):
|
||||
|
||||
@@ -7,11 +7,11 @@ const SCORE_TO_WIN = 10
|
||||
var score_left = 0
|
||||
var score_right = 0
|
||||
|
||||
onready var player2 = $Player2
|
||||
onready var score_left_node = $ScoreLeft
|
||||
onready var score_right_node = $ScoreRight
|
||||
onready var winner_left = $WinnerLeft
|
||||
onready var winner_right = $WinnerRight
|
||||
@onready var player2 = $Player2
|
||||
@onready var score_left_node = $ScoreLeft
|
||||
@onready var score_right_node = $ScoreRight
|
||||
@onready var winner_left = $WinnerLeft
|
||||
@onready var winner_right = $WinnerRight
|
||||
|
||||
func _ready():
|
||||
# By default, all nodes in server inherit from master,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/paddle.png-0e798fb0912613386507c9904d5cc01a.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/paddle.png-0e798fb0912613386507c9904d5cc01a.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://paddle.png"
|
||||
dest_files=[ "res://.import/paddle.png-0e798fb0912613386507c9904d5cc01a.stex" ]
|
||||
dest_files=["res://.godot/imported/paddle.png-0e798fb0912613386507c9904d5cc01a.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://logic/paddle.gd" type="Script" id=1]
|
||||
[ext_resource path="res://paddle.png" type="Texture" id=2]
|
||||
[ext_resource path="res://paddle.png" type="Texture2D" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 4.78568
|
||||
@@ -10,17 +10,17 @@ height = 23.6064
|
||||
[node name="Paddle" type="Area2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="."]
|
||||
[node name="Shape3D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="You" type="Label" parent="."]
|
||||
margin_left = -26.0
|
||||
margin_top = -33.0
|
||||
margin_right = 27.0
|
||||
margin_bottom = -19.0
|
||||
offset_left = -26.0
|
||||
offset_top = -33.0
|
||||
offset_right = 27.0
|
||||
offset_bottom = -19.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "You"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://logic/pong.gd" type="Script" id=1]
|
||||
[ext_resource path="res://separator.png" type="Texture" id=2]
|
||||
[ext_resource path="res://separator.png" type="Texture2D" id=2]
|
||||
[ext_resource path="res://paddle.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://ball.tscn" type="PackedScene" id=4]
|
||||
|
||||
@@ -9,44 +9,44 @@
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
margin_right = 640.0
|
||||
margin_bottom = 400.0
|
||||
color = Color( 0.141176, 0.152941, 0.164706, 1 )
|
||||
offset_right = 640.0
|
||||
offset_bottom = 400.0
|
||||
color = Color(0.141176, 0.152941, 0.164706, 1)
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Separator" type="Sprite" parent="."]
|
||||
position = Vector2( 320, 200 )
|
||||
[node name="Separator" type="Sprite2D" parent="."]
|
||||
position = Vector2(320, 200)
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="Player1" parent="." instance=ExtResource( 3 )]
|
||||
modulate = Color( 0, 1, 1, 1 )
|
||||
position = Vector2( 32.49, 188.622 )
|
||||
modulate = Color(0, 1, 1, 1)
|
||||
position = Vector2(32.49, 188.622)
|
||||
left = true
|
||||
|
||||
[node name="Player2" parent="." instance=ExtResource( 3 )]
|
||||
modulate = Color( 1, 0, 1, 1 )
|
||||
position = Vector2( 608.88, 188.622 )
|
||||
modulate = Color(1, 0, 1, 1)
|
||||
position = Vector2(608.88, 188.622)
|
||||
|
||||
[node name="Ball" parent="." instance=ExtResource( 4 )]
|
||||
position = Vector2( 320.387, 189.525 )
|
||||
position = Vector2(320.387, 189.525)
|
||||
|
||||
[node name="ScoreLeft" type="Label" parent="."]
|
||||
margin_left = 240.0
|
||||
margin_top = 10.0
|
||||
margin_right = 280.0
|
||||
margin_bottom = 30.0
|
||||
offset_left = 240.0
|
||||
offset_top = 10.0
|
||||
offset_right = 280.0
|
||||
offset_bottom = 30.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "0"
|
||||
align = 1
|
||||
|
||||
[node name="ScoreRight" type="Label" parent="."]
|
||||
margin_left = 360.0
|
||||
margin_top = 10.0
|
||||
margin_right = 400.0
|
||||
margin_bottom = 30.0
|
||||
offset_left = 360.0
|
||||
offset_top = 10.0
|
||||
offset_right = 400.0
|
||||
offset_bottom = 30.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "0"
|
||||
@@ -54,36 +54,36 @@ align = 1
|
||||
|
||||
[node name="WinnerLeft" type="Label" parent="."]
|
||||
visible = false
|
||||
margin_left = 190.0
|
||||
margin_top = 170.0
|
||||
margin_right = 267.0
|
||||
margin_bottom = 184.0
|
||||
offset_left = 190.0
|
||||
offset_top = 170.0
|
||||
offset_right = 267.0
|
||||
offset_bottom = 184.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "The Winner!"
|
||||
|
||||
[node name="WinnerRight" type="Label" parent="."]
|
||||
visible = false
|
||||
margin_left = 380.0
|
||||
margin_top = 170.0
|
||||
margin_right = 457.0
|
||||
margin_bottom = 184.0
|
||||
offset_left = 380.0
|
||||
offset_top = 170.0
|
||||
offset_right = 457.0
|
||||
offset_bottom = 184.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "The Winner!"
|
||||
|
||||
[node name="ExitGame" type="Button" parent="."]
|
||||
visible = false
|
||||
margin_left = 280.0
|
||||
margin_top = 340.0
|
||||
margin_right = 360.0
|
||||
margin_bottom = 360.0
|
||||
offset_left = 280.0
|
||||
offset_top = 340.0
|
||||
offset_right = 360.0
|
||||
offset_bottom = 360.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
text = "Exit Game"
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
offset = Vector2( 320, 200 )
|
||||
offset = Vector2(320, 200)
|
||||
current = true
|
||||
|
||||
[connection signal="pressed" from="ExitGame" to="." method="_on_exit_game_pressed"]
|
||||
|
||||
@@ -32,27 +32,27 @@ stretch_2d=true
|
||||
|
||||
[gdnative]
|
||||
|
||||
singletons=[ ]
|
||||
singletons=[]
|
||||
|
||||
[input]
|
||||
|
||||
move_down={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777234,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":90,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_up={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/separator.png-f981c8489b9148e2e1dc63398273da74.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://separator.png"
|
||||
dest_files=[ "res://.import/separator.png-f981c8489b9148e2e1dc63398273da74.stex" ]
|
||||
dest_files=["res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ var channel = peer.create_data_channel("chat", {"negotiated": true, "id": 1})
|
||||
|
||||
func _ready():
|
||||
# Connect all functions.
|
||||
peer.connect("ice_candidate_created", self, "_on_ice_candidate")
|
||||
peer.connect("session_description_created", self, "_on_session")
|
||||
peer.connect(&"ice_candidate_created", self._on_ice_candidate)
|
||||
peer.connect(&"session_description_created", self._on_session)
|
||||
|
||||
# Register to the local signaling server (see below for the implementation).
|
||||
Signaling.register(String(get_path()))
|
||||
|
||||
@@ -9,9 +9,9 @@ func _ready():
|
||||
add_child(p2)
|
||||
|
||||
# Wait a second and send message from P1
|
||||
yield(get_tree().create_timer(1), "timeout")
|
||||
await get_tree().create_timer(1).timeout
|
||||
p1.send_message("Hi from %s" % String(p1.get_path()))
|
||||
|
||||
# Wait a second and send message from P2
|
||||
yield(get_tree().create_timer(1), "timeout")
|
||||
await get_tree().create_timer(1).timeout
|
||||
p2.send_message("Hi from %s" % String(p2.get_path()))
|
||||
|
||||
@@ -17,10 +17,10 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="LinkButton" type="LinkButton" parent="CenterContainer"]
|
||||
margin_left = 239.0
|
||||
margin_top = 293.0
|
||||
margin_right = 785.0
|
||||
margin_bottom = 307.0
|
||||
offset_left = 239.0
|
||||
offset_top = 293.0
|
||||
offset_right = 785.0
|
||||
offset_bottom = 307.0
|
||||
text = "Make sure to download the GDNative WebRTC Plugin and place it in the project folder"
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
|
||||
@@ -10,25 +10,25 @@ var ch2 = p2.create_data_channel("chat", {"id": 1, "negotiated": true})
|
||||
func _ready():
|
||||
print(p1.create_data_channel("chat", {"id": 1, "negotiated": true}))
|
||||
# Connect P1 session created to itself to set local description.
|
||||
p1.connect("session_description_created", p1, "set_local_description")
|
||||
p1.connect(&"session_description_created", p1.set_local_description)
|
||||
# Connect P1 session and ICE created to p2 set remote description and candidates.
|
||||
p1.connect("session_description_created", p2, "set_remote_description")
|
||||
p1.connect("ice_candidate_created", p2, "add_ice_candidate")
|
||||
p1.connect(&"session_description_created", p2.set_remote_description)
|
||||
p1.connect(&"ice_candidate_created", p2.add_ice_candidate)
|
||||
|
||||
# Same for P2.
|
||||
p2.connect("session_description_created", p2, "set_local_description")
|
||||
p2.connect("session_description_created", p1, "set_remote_description")
|
||||
p2.connect("ice_candidate_created", p1, "add_ice_candidate")
|
||||
p2.connect(&"session_description_created", p2.set_local_description)
|
||||
p2.connect(&"session_description_created", p1.set_remote_description)
|
||||
p2.connect(&"ice_candidate_created", p1.add_ice_candidate)
|
||||
|
||||
# Let P1 create the offer.
|
||||
p1.create_offer()
|
||||
|
||||
# Wait a second and send message from P1.
|
||||
yield(get_tree().create_timer(1), "timeout")
|
||||
await get_tree().create_timer(1).timeout
|
||||
ch1.put_packet("Hi from P1".to_utf8())
|
||||
|
||||
# Wait a second and send message from P2.
|
||||
yield(get_tree().create_timer(1), "timeout")
|
||||
await get_tree().create_timer(1).timeout
|
||||
ch2.put_packet("Hi from P2".to_utf8())
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ window/stretch/aspect="expand"
|
||||
|
||||
[gdnative]
|
||||
|
||||
singletons=[ ]
|
||||
singletons=[]
|
||||
|
||||
[rendering]
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@ var rtc_mp: WebRTCMultiplayer = WebRTCMultiplayer.new()
|
||||
var sealed = false
|
||||
|
||||
func _init():
|
||||
connect("connected", self, "connected")
|
||||
connect("disconnected", self, "disconnected")
|
||||
connect(&"connected", self.connected)
|
||||
connect(&"disconnected", self.disconnected)
|
||||
|
||||
connect("offer_received", self, "offer_received")
|
||||
connect("answer_received", self, "answer_received")
|
||||
connect("candidate_received", self, "candidate_received")
|
||||
connect(&"offer_received", self.offer_received)
|
||||
connect(&"answer_received", self.answer_received)
|
||||
connect(&"candidate_received", self.candidate_received)
|
||||
|
||||
connect("lobby_joined", self, "lobby_joined")
|
||||
connect("lobby_sealed", self, "lobby_sealed")
|
||||
connect("peer_connected", self, "peer_connected")
|
||||
connect("peer_disconnected", self, "peer_disconnected")
|
||||
connect(&"lobby_joined", self.lobby_joined)
|
||||
connect(&"lobby_sealed", self.lobby_sealed)
|
||||
connect(&"peer_connected", self.peer_connected)
|
||||
connect(&"peer_disconnected", self.peer_disconnected)
|
||||
|
||||
|
||||
func start(url, lobby = ""):
|
||||
@@ -34,8 +34,8 @@ func _create_peer(id):
|
||||
peer.initialize({
|
||||
"iceServers": [ { "urls": ["stun:stun.l.google.com:19302"] } ]
|
||||
})
|
||||
peer.connect("session_description_created", self, "_offer_created", [id])
|
||||
peer.connect("ice_candidate_created", self, "_new_ice_candidate", [id])
|
||||
peer.connect(&"session_description_created", self._offer_created, [id])
|
||||
peer.connect(&"ice_candidate_created", self._new_ice_candidate, [id])
|
||||
rtc_mp.add_peer(peer, id)
|
||||
if id > rtc_mp.get_unique_id():
|
||||
peer.create_offer()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Node
|
||||
|
||||
export var autojoin = true
|
||||
export var lobby = "" # Will create a new lobby if empty.
|
||||
@export var autojoin = true
|
||||
@export var lobby = "" # Will create a new lobby if empty.
|
||||
|
||||
var client: WebSocketClient = WebSocketClient.new()
|
||||
var code = 1000
|
||||
@@ -18,11 +18,11 @@ signal candidate_received(id, mid, index, sdp)
|
||||
signal lobby_sealed()
|
||||
|
||||
func _init():
|
||||
client.connect("data_received", self, "_parse_msg")
|
||||
client.connect("connection_established", self, "_connected")
|
||||
client.connect("connection_closed", self, "_closed")
|
||||
client.connect("connection_error", self, "_closed")
|
||||
client.connect("server_close_request", self, "_close_request")
|
||||
client.connect(&"data_received", self._parse_msg)
|
||||
client.connect(&"connection_established", self._connected)
|
||||
client.connect(&"connection_closed", self._closed)
|
||||
client.connect(&"connection_error", self._closed)
|
||||
client.connect(&"server_close_request", self._close_request)
|
||||
|
||||
|
||||
func connect_to_url(url):
|
||||
@@ -54,7 +54,7 @@ func _connected(protocol = ""):
|
||||
func _parse_msg():
|
||||
var pkt_str: String = client.get_peer(1).get_packet().get_string_from_utf8()
|
||||
|
||||
var req: PoolStringArray = pkt_str.split("\n", true, 1)
|
||||
var req: PackedStringArray = pkt_str.split("\n", true, 1)
|
||||
if req.size() != 2: # Invalid request size
|
||||
return
|
||||
|
||||
@@ -70,7 +70,7 @@ func _parse_msg():
|
||||
return
|
||||
|
||||
var src_str: String = type.substr(3, type.length() - 3)
|
||||
if not src_str.is_valid_integer(): # Source id is not an integer
|
||||
if not src_str.is_valid_int(): # Source id is not an integer
|
||||
return
|
||||
|
||||
var src_id: int = int(src_str)
|
||||
@@ -91,10 +91,10 @@ func _parse_msg():
|
||||
emit_signal("answer_received", src_id, req[1])
|
||||
elif type.begins_with("C: "):
|
||||
# Candidate received
|
||||
var candidate: PoolStringArray = req[1].split("\n", false)
|
||||
var candidate: PackedStringArray = req[1].split("\n", false)
|
||||
if candidate.size() != 3:
|
||||
return
|
||||
if not candidate[1].is_valid_integer():
|
||||
if not candidate[1].is_valid_int():
|
||||
return
|
||||
emit_signal("candidate_received", src_id, candidate[0], int(candidate[1]), candidate[2])
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
extends Control
|
||||
|
||||
onready var client = $Client
|
||||
@onready var client = $Client
|
||||
|
||||
func _ready():
|
||||
client.connect("lobby_joined", self, "_lobby_joined")
|
||||
client.connect("lobby_sealed", self, "_lobby_sealed")
|
||||
client.connect("connected", self, "_connected")
|
||||
client.connect("disconnected", self, "_disconnected")
|
||||
client.rtc_mp.connect("peer_connected", self, "_mp_peer_connected")
|
||||
client.rtc_mp.connect("peer_disconnected", self, "_mp_peer_disconnected")
|
||||
client.rtc_mp.connect("server_disconnected", self, "_mp_server_disconnect")
|
||||
client.rtc_mp.connect("connection_succeeded", self, "_mp_connected")
|
||||
client.connect(&"lobby_joined", self._lobby_joined)
|
||||
client.connect(&"lobby_sealed", self._lobby_sealed)
|
||||
client.connect(&"connected", self._connected)
|
||||
client.connect(&"disconnected", self._disconnected)
|
||||
client.rtc_mp.connect(&"peer_connected", self._mp_peer_connected)
|
||||
client.rtc_mp.connect(&"peer_disconnected", self._mp_peer_disconnected)
|
||||
client.rtc_mp.connect(&"server_disconnected", self._mp_server_disconnect)
|
||||
client.rtc_mp.connect(&"connection_succeeded", self._mp_connected)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
[ext_resource path="res://client/multiplayer_client.gd" type="Script" id=2]
|
||||
|
||||
[node name="ClientUI" type="Control"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 1 )
|
||||
@@ -25,78 +25,78 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="Connect" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/Connect"]
|
||||
margin_top = 5.0
|
||||
margin_right = 73.0
|
||||
margin_bottom = 19.0
|
||||
offset_top = 5.0
|
||||
offset_right = 73.0
|
||||
offset_bottom = 19.0
|
||||
text = "Connect to:"
|
||||
|
||||
[node name="Host" type="LineEdit" parent="VBoxContainer/Connect"]
|
||||
margin_left = 77.0
|
||||
margin_right = 921.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 77.0
|
||||
offset_right = 921.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
text = "ws://localhost:9080"
|
||||
|
||||
[node name="Room" type="Label" parent="VBoxContainer/Connect"]
|
||||
margin_left = 925.0
|
||||
margin_right = 962.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 925.0
|
||||
offset_right = 962.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_vertical = 5
|
||||
text = "Room"
|
||||
valign = 1
|
||||
|
||||
[node name="RoomSecret" type="LineEdit" parent="VBoxContainer/Connect"]
|
||||
margin_left = 966.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 966.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 24.0
|
||||
placeholder_text = "secret"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_top = 32.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 52.0
|
||||
offset_top = 32.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 52.0
|
||||
custom_constants/separation = 10
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Start" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_right = 41.0
|
||||
margin_bottom = 20.0
|
||||
offset_right = 41.0
|
||||
offset_bottom = 20.0
|
||||
text = "Start"
|
||||
|
||||
[node name="Stop" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_left = 51.0
|
||||
margin_right = 91.0
|
||||
margin_bottom = 20.0
|
||||
offset_left = 51.0
|
||||
offset_right = 91.0
|
||||
offset_bottom = 20.0
|
||||
text = "Stop"
|
||||
|
||||
[node name="Seal" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_left = 101.0
|
||||
margin_right = 139.0
|
||||
margin_bottom = 20.0
|
||||
offset_left = 101.0
|
||||
offset_right = 139.0
|
||||
offset_bottom = 20.0
|
||||
text = "Seal"
|
||||
|
||||
[node name="Ping" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_left = 149.0
|
||||
margin_right = 188.0
|
||||
margin_bottom = 20.0
|
||||
offset_left = 149.0
|
||||
offset_right = 188.0
|
||||
offset_bottom = 20.0
|
||||
text = "Ping"
|
||||
|
||||
[node name="Peers" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_left = 198.0
|
||||
margin_right = 280.0
|
||||
margin_bottom = 20.0
|
||||
offset_left = 198.0
|
||||
offset_right = 280.0
|
||||
offset_bottom = 20.0
|
||||
text = "Print peers"
|
||||
|
||||
[node name="TextEdit" type="TextEdit" parent="VBoxContainer"]
|
||||
margin_top = 60.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
offset_top = 60.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_vertical = 3
|
||||
readonly = true
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ anchor_left = 0.0136719
|
||||
anchor_top = 0.0166667
|
||||
anchor_right = 0.986328
|
||||
anchor_bottom = 0.983333
|
||||
margin_top = 4.32134e-07
|
||||
margin_bottom = -9.53674e-06
|
||||
offset_top = 4.32134e-07
|
||||
offset_bottom = -9.53674e-06
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
@@ -25,48 +25,48 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="Signaling" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_right = 995.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 995.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/Signaling"]
|
||||
margin_top = 5.0
|
||||
margin_right = 104.0
|
||||
margin_bottom = 19.0
|
||||
offset_top = 5.0
|
||||
offset_right = 104.0
|
||||
offset_bottom = 19.0
|
||||
text = "Signaling server:"
|
||||
|
||||
[node name="Port" type="SpinBox" parent="VBoxContainer/Signaling"]
|
||||
margin_left = 108.0
|
||||
margin_right = 182.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 108.0
|
||||
offset_right = 182.0
|
||||
offset_bottom = 24.0
|
||||
min_value = 1025.0
|
||||
max_value = 65535.0
|
||||
value = 9080.0
|
||||
|
||||
[node name="ListenButton" type="Button" parent="VBoxContainer/Signaling"]
|
||||
margin_left = 186.0
|
||||
margin_right = 237.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 186.0
|
||||
offset_right = 237.0
|
||||
offset_bottom = 24.0
|
||||
toggle_mode = true
|
||||
text = "Listen"
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="VBoxContainer/Signaling"]
|
||||
margin_left = 241.0
|
||||
margin_right = 995.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 241.0
|
||||
offset_right = 995.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="LinkButton" type="LinkButton" parent="VBoxContainer/Signaling/CenterContainer"]
|
||||
margin_left = 104.0
|
||||
margin_top = 5.0
|
||||
margin_right = 650.0
|
||||
margin_bottom = 19.0
|
||||
offset_left = 104.0
|
||||
offset_top = 5.0
|
||||
offset_right = 650.0
|
||||
offset_bottom = 19.0
|
||||
text = "Make sure to download the GDNative WebRTC Plugin and place it in the project folder"
|
||||
|
||||
[node name="Clients" type="GridContainer" parent="VBoxContainer"]
|
||||
margin_top = 74.0
|
||||
margin_right = 995.0
|
||||
margin_bottom = 579.0
|
||||
offset_top = 74.0
|
||||
offset_right = 995.0
|
||||
offset_bottom = 579.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_constants/vseparation = 15
|
||||
@@ -74,24 +74,24 @@ custom_constants/hseparation = 15
|
||||
columns = 2
|
||||
|
||||
[node name="ClientUI" parent="VBoxContainer/Clients" instance=ExtResource( 2 )]
|
||||
margin_right = 490.0
|
||||
margin_bottom = 245.0
|
||||
offset_right = 490.0
|
||||
offset_bottom = 245.0
|
||||
|
||||
[node name="ClientUI2" parent="VBoxContainer/Clients" instance=ExtResource( 2 )]
|
||||
margin_left = 505.0
|
||||
margin_right = 995.0
|
||||
margin_bottom = 245.0
|
||||
offset_left = 505.0
|
||||
offset_right = 995.0
|
||||
offset_bottom = 245.0
|
||||
|
||||
[node name="ClientUI3" parent="VBoxContainer/Clients" instance=ExtResource( 2 )]
|
||||
margin_top = 260.0
|
||||
margin_right = 490.0
|
||||
margin_bottom = 505.0
|
||||
offset_top = 260.0
|
||||
offset_right = 490.0
|
||||
offset_bottom = 505.0
|
||||
|
||||
[node name="ClientUI4" parent="VBoxContainer/Clients" instance=ExtResource( 2 )]
|
||||
margin_left = 505.0
|
||||
margin_top = 260.0
|
||||
margin_right = 995.0
|
||||
margin_bottom = 505.0
|
||||
offset_left = 505.0
|
||||
offset_top = 260.0
|
||||
offset_right = 995.0
|
||||
offset_bottom = 505.0
|
||||
|
||||
[node name="Server" type="Node" parent="."]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
@@ -31,8 +31,8 @@ window/stretch/aspect="expand"
|
||||
|
||||
[gdnative]
|
||||
|
||||
singletons=[ ]
|
||||
singletons_disabled=[ ]
|
||||
singletons=[]
|
||||
singletons_disabled=[]
|
||||
|
||||
[network]
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ var lobbies: Dictionary = {}
|
||||
var server: WebSocketServer = WebSocketServer.new()
|
||||
var peers: Dictionary = {}
|
||||
|
||||
class Peer extends Reference:
|
||||
class Peer extends RefCounted:
|
||||
var id = -1
|
||||
var lobby = ""
|
||||
var time = OS.get_ticks_msec()
|
||||
@@ -21,7 +21,7 @@ class Peer extends Reference:
|
||||
|
||||
|
||||
|
||||
class Lobby extends Reference:
|
||||
class Lobby extends RefCounted:
|
||||
var peers: Array = []
|
||||
var host: int = -1
|
||||
var sealed: bool = false
|
||||
@@ -76,9 +76,9 @@ class Lobby extends Reference:
|
||||
|
||||
|
||||
func _init():
|
||||
server.connect("data_received", self, "_on_data")
|
||||
server.connect("client_connected", self, "_peer_connected")
|
||||
server.connect("client_disconnected", self, "_peer_disconnected")
|
||||
server.connect(&"data_received", self._on_data)
|
||||
server.connect(&"client_connected", self._peer_connected)
|
||||
server.connect(&"client_disconnected", self._peer_disconnected)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
@@ -182,7 +182,7 @@ func _parse_msg(id) -> bool:
|
||||
return lobby.seal(id, server)
|
||||
|
||||
var dest_str: String = type.substr(3, type.length() - 3)
|
||||
if not dest_str.is_valid_integer(): # Destination id is not an integer
|
||||
if not dest_str.is_valid_int(): # Destination id is not an integer
|
||||
return false
|
||||
|
||||
var dest_id: int = int(dest_str)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extends Node
|
||||
|
||||
onready var _log_dest = get_parent().get_node("Panel/VBoxContainer/RichTextLabel")
|
||||
@onready var _log_dest = get_parent().get_node(^"Panel/VBoxContainer/RichTextLabel")
|
||||
|
||||
var _client = WebSocketClient.new()
|
||||
var _write_mode = WebSocketPeer.WRITE_MODE_BINARY
|
||||
@@ -8,16 +8,16 @@ var _use_multiplayer = true
|
||||
var last_connected_client = 0
|
||||
|
||||
func _init():
|
||||
_client.connect("connection_established", self, "_client_connected")
|
||||
_client.connect("connection_error", self, "_client_disconnected")
|
||||
_client.connect("connection_closed", self, "_client_disconnected")
|
||||
_client.connect("server_close_request", self, "_client_close_request")
|
||||
_client.connect("data_received", self, "_client_received")
|
||||
_client.connect(&"connection_established", self._client_connected)
|
||||
_client.connect(&"connection_error", self._client_disconnected)
|
||||
_client.connect(&"connection_closed", self._client_disconnected)
|
||||
_client.connect(&"server_close_request", self._client_close_request)
|
||||
_client.connect(&"data_received", self._client_received)
|
||||
|
||||
_client.connect("peer_packet", self, "_client_received")
|
||||
_client.connect("peer_connected", self, "_peer_connected")
|
||||
_client.connect("connection_succeeded", self, "_client_connected", ["multiplayer_protocol"])
|
||||
_client.connect("connection_failed", self, "_client_disconnected")
|
||||
_client.connect(&"peer_packet", self._client_received)
|
||||
_client.connect(&"peer_connected", self._peer_connected)
|
||||
_client.connect(&"connection_succeeded", self._client_connected, ["multiplayer_protocol"])
|
||||
_client.connect(&"connection_failed", self._client_disconnected)
|
||||
|
||||
|
||||
func _client_close_request(code, reason):
|
||||
|
||||
@@ -20,65 +20,65 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="Connect" type="HBoxContainer" parent="Panel/VBoxContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="Host" type="LineEdit" parent="Panel/VBoxContainer/Connect"]
|
||||
margin_right = 956.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 956.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
text = "ws://localhost:8000/test/"
|
||||
placeholder_text = "ws://my.server/path/"
|
||||
|
||||
[node name="Connect" type="Button" parent="Panel/VBoxContainer/Connect"]
|
||||
margin_left = 960.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 960.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 24.0
|
||||
toggle_mode = true
|
||||
text = "Connect"
|
||||
|
||||
[node name="Settings" type="HBoxContainer" parent="Panel/VBoxContainer"]
|
||||
margin_top = 28.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 52.0
|
||||
offset_top = 28.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 52.0
|
||||
|
||||
[node name="Mode" type="OptionButton" parent="Panel/VBoxContainer/Settings"]
|
||||
margin_right = 29.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 29.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="Multiplayer" type="CheckBox" parent="Panel/VBoxContainer/Settings"]
|
||||
margin_left = 33.0
|
||||
margin_right = 159.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 33.0
|
||||
offset_right = 159.0
|
||||
offset_bottom = 24.0
|
||||
pressed = true
|
||||
text = "Multiplayer API"
|
||||
|
||||
[node name="Destination" type="OptionButton" parent="Panel/VBoxContainer/Settings"]
|
||||
margin_left = 163.0
|
||||
margin_right = 192.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 163.0
|
||||
offset_right = 192.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="Send" type="HBoxContainer" parent="Panel/VBoxContainer"]
|
||||
margin_top = 56.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 80.0
|
||||
offset_top = 56.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 80.0
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Panel/VBoxContainer/Send"]
|
||||
margin_right = 977.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 977.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Enter some text to send..."
|
||||
|
||||
[node name="Send" type="Button" parent="Panel/VBoxContainer/Send"]
|
||||
margin_left = 981.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 981.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 24.0
|
||||
text = "Send"
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer"]
|
||||
margin_top = 84.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
offset_top = 84.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Client" type="Node" parent="."]
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
extends Control
|
||||
|
||||
onready var _client = $Client
|
||||
onready var _log_dest = $Panel/VBoxContainer/RichTextLabel
|
||||
onready var _line_edit = $Panel/VBoxContainer/Send/LineEdit
|
||||
onready var _host = $Panel/VBoxContainer/Connect/Host
|
||||
onready var _multiplayer = $Panel/VBoxContainer/Settings/Multiplayer
|
||||
onready var _write_mode = $Panel/VBoxContainer/Settings/Mode
|
||||
onready var _destination = $Panel/VBoxContainer/Settings/Destination
|
||||
@onready var _client = $Client
|
||||
@onready var _log_dest = $Panel/VBoxContainer/RichTextLabel
|
||||
@onready var _line_edit = $Panel/VBoxContainer/Send/LineEdit
|
||||
@onready var _host = $Panel/VBoxContainer/Connect/Host
|
||||
@onready var _multiplayer = $Panel/VBoxContainer/Settings/Multiplayer
|
||||
@onready var _write_mode = $Panel/VBoxContainer/Settings/Mode
|
||||
@onready var _destination = $Panel/VBoxContainer/Settings/Destination
|
||||
|
||||
func _ready():
|
||||
_write_mode.clear()
|
||||
@@ -53,7 +53,7 @@ func _on_Connect_toggled( pressed ):
|
||||
_multiplayer.disabled = true
|
||||
if _host.text != "":
|
||||
Utils._log(_log_dest, "Connecting to host: %s" % [_host.text])
|
||||
var supported_protocols = PoolStringArray(["my-protocol2", "my-protocol", "binary"])
|
||||
var supported_protocols = PackedStringArray(["my-protocol2", "my-protocol", "binary"])
|
||||
_client.connect_to_url(_host.text, supported_protocols, multiplayer)
|
||||
else:
|
||||
_destination.disabled = false
|
||||
|
||||
@@ -16,38 +16,38 @@ custom_constants/separation = 20
|
||||
[node name="ServerControl" parent="Box" instance=ExtResource( 1 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 502.0
|
||||
margin_bottom = 600.0
|
||||
offset_right = 502.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Box"]
|
||||
margin_left = 522.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
offset_left = 522.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Client" parent="Box/VBoxContainer" instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 502.0
|
||||
margin_bottom = 197.0
|
||||
offset_right = 502.0
|
||||
offset_bottom = 197.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Client2" parent="Box/VBoxContainer" instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 201.0
|
||||
margin_right = 502.0
|
||||
margin_bottom = 398.0
|
||||
offset_top = 201.0
|
||||
offset_right = 502.0
|
||||
offset_bottom = 398.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Client3" parent="Box/VBoxContainer" instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 402.0
|
||||
margin_right = 502.0
|
||||
margin_bottom = 600.0
|
||||
offset_top = 402.0
|
||||
offset_right = 502.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Utils="*res://utils.gd"
|
||||
|
||||
[gdnative]
|
||||
|
||||
singletons=[ ]
|
||||
singletons=[]
|
||||
|
||||
[rendering]
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extends Node
|
||||
|
||||
onready var _log_dest = get_parent().get_node("Panel/VBoxContainer/RichTextLabel")
|
||||
@onready var _log_dest = get_parent().get_node(^"Panel/VBoxContainer/RichTextLabel")
|
||||
|
||||
var _server = WebSocketServer.new()
|
||||
var _clients = {}
|
||||
@@ -9,14 +9,14 @@ var _use_multiplayer = true
|
||||
var last_connected_client = 0
|
||||
|
||||
func _init():
|
||||
_server.connect("client_connected", self, "_client_connected")
|
||||
_server.connect("client_disconnected", self, "_client_disconnected")
|
||||
_server.connect("client_close_request", self, "_client_close_request")
|
||||
_server.connect("data_received", self, "_client_receive")
|
||||
_server.connect(&"client_connected", self._client_connected)
|
||||
_server.connect(&"client_disconnected", self._client_disconnected)
|
||||
_server.connect(&"client_close_request", self._client_close_request)
|
||||
_server.connect(&"data_received", self._client_receive)
|
||||
|
||||
_server.connect("peer_packet", self, "_client_receive")
|
||||
_server.connect("peer_connected", self, "_client_connected", ["multiplayer_protocol"])
|
||||
_server.connect("peer_disconnected", self, "_client_disconnected")
|
||||
_server.connect(&"peer_packet", self._client_receive)
|
||||
_server.connect(&"peer_connected", self._client_connected, ["multiplayer_protocol"])
|
||||
_server.connect(&"peer_disconnected", self._client_disconnected)
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
|
||||
@@ -23,64 +23,64 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="Port" type="SpinBox" parent="Panel/VBoxContainer/HBoxContainer"]
|
||||
margin_right = 74.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 74.0
|
||||
offset_bottom = 24.0
|
||||
min_value = 1.0
|
||||
max_value = 65535.0
|
||||
value = 8000.0
|
||||
|
||||
[node name="Listen" type="Button" parent="Panel/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 78.0
|
||||
margin_right = 129.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 78.0
|
||||
offset_right = 129.0
|
||||
offset_bottom = 24.0
|
||||
toggle_mode = true
|
||||
text = "Listen"
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="Panel/VBoxContainer"]
|
||||
margin_top = 28.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 52.0
|
||||
offset_top = 28.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 52.0
|
||||
|
||||
[node name="WriteMode" type="OptionButton" parent="Panel/VBoxContainer/HBoxContainer2"]
|
||||
margin_right = 29.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 29.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="MPAPI" type="CheckBox" parent="Panel/VBoxContainer/HBoxContainer2"]
|
||||
margin_left = 33.0
|
||||
margin_right = 159.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 33.0
|
||||
offset_right = 159.0
|
||||
offset_bottom = 24.0
|
||||
pressed = true
|
||||
text = "Multiplayer API"
|
||||
|
||||
[node name="Destination" type="OptionButton" parent="Panel/VBoxContainer/HBoxContainer2"]
|
||||
margin_left = 163.0
|
||||
margin_right = 192.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 163.0
|
||||
offset_right = 192.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="HBoxContainer3" type="HBoxContainer" parent="Panel/VBoxContainer"]
|
||||
margin_top = 56.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 80.0
|
||||
offset_top = 56.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 80.0
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Panel/VBoxContainer/HBoxContainer3"]
|
||||
margin_right = 977.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 977.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Send" type="Button" parent="Panel/VBoxContainer/HBoxContainer3"]
|
||||
margin_left = 981.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 981.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 24.0
|
||||
text = "Send"
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer"]
|
||||
margin_top = 84.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
offset_top = 84.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[connection signal="toggled" from="Panel/VBoxContainer/HBoxContainer/Listen" to="." method="_on_Listen_toggled"]
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
extends Control
|
||||
|
||||
onready var _server = $Server
|
||||
onready var _port = $Panel/VBoxContainer/HBoxContainer/Port
|
||||
onready var _line_edit = $Panel/VBoxContainer/HBoxContainer3/LineEdit
|
||||
onready var _write_mode = $Panel/VBoxContainer/HBoxContainer2/WriteMode
|
||||
onready var _log_dest = $Panel/VBoxContainer/RichTextLabel
|
||||
onready var _multiplayer = $Panel/VBoxContainer/HBoxContainer2/MPAPI
|
||||
onready var _destination = $Panel/VBoxContainer/HBoxContainer2/Destination
|
||||
@onready var _server = $Server
|
||||
@onready var _port = $Panel/VBoxContainer/HBoxContainer/Port
|
||||
@onready var _line_edit = $Panel/VBoxContainer/HBoxContainer3/LineEdit
|
||||
@onready var _write_mode = $Panel/VBoxContainer/HBoxContainer2/WriteMode
|
||||
@onready var _log_dest = $Panel/VBoxContainer/RichTextLabel
|
||||
@onready var _multiplayer = $Panel/VBoxContainer/HBoxContainer2/MPAPI
|
||||
@onready var _destination = $Panel/VBoxContainer/HBoxContainer2/Destination
|
||||
|
||||
func _ready():
|
||||
_write_mode.clear()
|
||||
@@ -29,7 +29,7 @@ func _on_Listen_toggled(pressed):
|
||||
if pressed:
|
||||
var use_multiplayer = _multiplayer.pressed
|
||||
_multiplayer.disabled = true
|
||||
var supported_protocols = PoolStringArray(["my-protocol", "binary"])
|
||||
var supported_protocols = PackedStringArray(["my-protocol", "binary"])
|
||||
var port = int(_port.value)
|
||||
if use_multiplayer:
|
||||
_write_mode.disabled = true
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
extends Node
|
||||
|
||||
# The URL we will connect to.
|
||||
@export
|
||||
var websocket_url = "ws://localhost:9080"
|
||||
@export var websocket_url = "ws://localhost:9080"
|
||||
|
||||
# Our WebSocketClient instance.
|
||||
var _client = WebSocketClient.new()
|
||||
|
||||
func _ready():
|
||||
# Connect base signals to get notified of connection open, close, and errors.
|
||||
_client.connect("connection_closed", _closed)
|
||||
_client.connect("connection_error", _closed)
|
||||
_client.connect("connection_established", _connected)
|
||||
_client.connect(&"connection_closed", _closed)
|
||||
_client.connect(&"connection_error", _closed)
|
||||
_client.connect(&"connection_established", _connected)
|
||||
# This signal is emitted when not using the Multiplayer API every time
|
||||
# a full packet is received.
|
||||
# Alternatively, you could check get_peer(1).get_available_packets() in a loop.
|
||||
_client.connect("data_received", _on_data)
|
||||
_client.connect(&"data_received", _on_data)
|
||||
|
||||
# Initiate connection to the given URL.
|
||||
var err = _client.connect_to_url(websocket_url)
|
||||
|
||||
@@ -8,14 +8,14 @@ var _server = WebSocketServer.new()
|
||||
func _ready():
|
||||
# Connect base signals to get notified of new client connections,
|
||||
# disconnections, and disconnect requests.
|
||||
_server.connect("client_connected", _connected)
|
||||
_server.connect("client_disconnected", _disconnected)
|
||||
_server.connect("client_close_request", _close_request)
|
||||
_server.connect(&"client_connected", _connected)
|
||||
_server.connect(&"client_disconnected", _disconnected)
|
||||
_server.connect(&"client_close_request", _close_request)
|
||||
# This signal is emitted when not using the Multiplayer API every time a
|
||||
# full packet is received.
|
||||
# Alternatively, you could check get_peer(PEER_ID).get_available_packets()
|
||||
# in a loop for each connected peer.
|
||||
_server.connect("data_received", _on_data)
|
||||
_server.connect(&"data_received", _on_data)
|
||||
# Start listening on the given port.
|
||||
var err = _server.listen(PORT)
|
||||
if err != OK:
|
||||
|
||||
@@ -18,33 +18,33 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="HBoxContainer"]
|
||||
margin_right = 510.0
|
||||
margin_bottom = 600.0
|
||||
offset_right = 510.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
|
||||
margin_left = 514.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxContainer/VBoxContainer"]
|
||||
margin_right = 510.0
|
||||
margin_bottom = 14.0
|
||||
offset_right = 510.0
|
||||
offset_bottom = 14.0
|
||||
text = "Players:"
|
||||
|
||||
[node name="ItemList" type="ItemList" parent="HBoxContainer/VBoxContainer"]
|
||||
margin_top = 18.0
|
||||
margin_right = 510.0
|
||||
margin_bottom = 576.0
|
||||
offset_top = 18.0
|
||||
offset_right = 510.0
|
||||
offset_bottom = 576.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
same_column_width = true
|
||||
|
||||
[node name="Action" type="Button" parent="HBoxContainer/VBoxContainer"]
|
||||
margin_top = 580.0
|
||||
margin_right = 510.0
|
||||
margin_bottom = 600.0
|
||||
offset_top = 580.0
|
||||
offset_right = 510.0
|
||||
offset_bottom = 600.0
|
||||
disabled = true
|
||||
text = "Do Action!"
|
||||
|
||||
|
||||
@@ -18,95 +18,95 @@ anchor_bottom = 1.0
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 20.0
|
||||
margin_top = 20.0
|
||||
margin_right = -20.0
|
||||
margin_bottom = -20.0
|
||||
offset_left = 20.0
|
||||
offset_top = 20.0
|
||||
offset_right = -20.0
|
||||
offset_bottom = -20.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 984.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="Label" type="Label" parent="Panel/VBoxContainer/HBoxContainer"]
|
||||
margin_top = 5.0
|
||||
margin_right = 326.0
|
||||
margin_bottom = 19.0
|
||||
offset_top = 5.0
|
||||
offset_right = 326.0
|
||||
offset_bottom = 19.0
|
||||
size_flags_horizontal = 3
|
||||
text = "Name"
|
||||
|
||||
[node name="NameEdit" type="LineEdit" parent="Panel/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 330.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 330.0
|
||||
offset_right = 984.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 2.0
|
||||
text = "A Godot User"
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="Panel/VBoxContainer"]
|
||||
margin_top = 28.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 52.0
|
||||
offset_top = 28.0
|
||||
offset_right = 984.0
|
||||
offset_bottom = 52.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer/HBoxContainer2"]
|
||||
margin_right = 326.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 326.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Host" type="Button" parent="Panel/VBoxContainer/HBoxContainer2/HBoxContainer"]
|
||||
margin_right = 42.0
|
||||
margin_bottom = 24.0
|
||||
offset_right = 42.0
|
||||
offset_bottom = 24.0
|
||||
text = "Host"
|
||||
|
||||
[node name="Control" type="Control" parent="Panel/VBoxContainer/HBoxContainer2/HBoxContainer"]
|
||||
margin_left = 46.0
|
||||
margin_right = 241.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 46.0
|
||||
offset_right = 241.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Connect" type="Button" parent="Panel/VBoxContainer/HBoxContainer2/HBoxContainer"]
|
||||
margin_left = 245.0
|
||||
margin_right = 326.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 245.0
|
||||
offset_right = 326.0
|
||||
offset_bottom = 24.0
|
||||
text = "Connect to"
|
||||
|
||||
[node name="Disconnect" type="Button" parent="Panel/VBoxContainer/HBoxContainer2/HBoxContainer"]
|
||||
visible = false
|
||||
margin_left = 68.0
|
||||
margin_right = 152.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 68.0
|
||||
offset_right = 152.0
|
||||
offset_bottom = 24.0
|
||||
text = "Disconnect"
|
||||
|
||||
[node name="Hostname" type="LineEdit" parent="Panel/VBoxContainer/HBoxContainer2"]
|
||||
margin_left = 330.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 24.0
|
||||
offset_left = 330.0
|
||||
offset_right = 984.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 2.0
|
||||
text = "localhost"
|
||||
placeholder_text = "localhost"
|
||||
|
||||
[node name="Control" type="Control" parent="Panel/VBoxContainer"]
|
||||
margin_top = 56.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 76.0
|
||||
rect_min_size = Vector2( 0, 20 )
|
||||
offset_top = 56.0
|
||||
offset_right = 984.0
|
||||
offset_bottom = 76.0
|
||||
rect_min_size = Vector2(0, 20)
|
||||
|
||||
[node name="Game" parent="Panel/VBoxContainer" instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 80.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 560.0
|
||||
offset_top = 80.0
|
||||
offset_right = 984.0
|
||||
offset_bottom = 560.0
|
||||
|
||||
[node name="AcceptDialog" type="AcceptDialog" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -200.0
|
||||
margin_top = -100.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 100.0
|
||||
offset_left = -200.0
|
||||
offset_top = -100.0
|
||||
offset_right = 200.0
|
||||
offset_bottom = 100.0
|
||||
dialog_text = "Connection closed"
|
||||
|
||||
[connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer2/HBoxContainer/Host" to="." method="_on_Host_pressed"]
|
||||
|
||||
@@ -2,8 +2,8 @@ extends Control
|
||||
|
||||
const _crown = preload("res://img/crown.png")
|
||||
|
||||
onready var _list = $HBoxContainer/VBoxContainer/ItemList
|
||||
onready var _action = $HBoxContainer/VBoxContainer/Action
|
||||
@onready var _list = $HBoxContainer/VBoxContainer/ItemList
|
||||
@onready var _action = $HBoxContainer/VBoxContainer/Action
|
||||
|
||||
var _players = []
|
||||
var _turn = -1
|
||||
|
||||
@@ -3,19 +3,19 @@ extends Control
|
||||
const DEF_PORT = 8080
|
||||
const PROTO_NAME = "ludus"
|
||||
|
||||
onready var _host_btn = $Panel/VBoxContainer/HBoxContainer2/HBoxContainer/Host
|
||||
onready var _connect_btn = $Panel/VBoxContainer/HBoxContainer2/HBoxContainer/Connect
|
||||
onready var _disconnect_btn = $Panel/VBoxContainer/HBoxContainer2/HBoxContainer/Disconnect
|
||||
onready var _name_edit = $Panel/VBoxContainer/HBoxContainer/NameEdit
|
||||
onready var _host_edit = $Panel/VBoxContainer/HBoxContainer2/Hostname
|
||||
onready var _game = $Panel/VBoxContainer/Game
|
||||
@onready var _host_btn = $Panel/VBoxContainer/HBoxContainer2/HBoxContainer/Host
|
||||
@onready var _connect_btn = $Panel/VBoxContainer/HBoxContainer2/HBoxContainer/Connect
|
||||
@onready var _disconnect_btn = $Panel/VBoxContainer/HBoxContainer2/HBoxContainer/Disconnect
|
||||
@onready var _name_edit = $Panel/VBoxContainer/HBoxContainer/NameEdit
|
||||
@onready var _host_edit = $Panel/VBoxContainer/HBoxContainer2/Hostname
|
||||
@onready var _game = $Panel/VBoxContainer/Game
|
||||
|
||||
var peer = null
|
||||
|
||||
func _ready():
|
||||
#warning-ignore-all:return_value_discarded
|
||||
get_tree().connect("network_peer_disconnected", self, "_peer_disconnected")
|
||||
get_tree().connect("network_peer_connected", self, "_peer_connected")
|
||||
get_tree().connect(&"network_peer_disconnected", self._peer_disconnected)
|
||||
get_tree().connect(&"network_peer_connected", self._peer_connected)
|
||||
$AcceptDialog.get_label().align = Label.ALIGN_CENTER
|
||||
$AcceptDialog.get_label().valign = Label.VALIGN_CENTER
|
||||
# Set the player name according to the system username. Fallback to the path.
|
||||
@@ -46,11 +46,11 @@ func stop_game():
|
||||
|
||||
func _close_network():
|
||||
if get_tree().is_connected("server_disconnected", self, "_close_network"):
|
||||
get_tree().disconnect("server_disconnected", self, "_close_network")
|
||||
get_tree().disconnect(&"server_disconnected", self._close_network)
|
||||
if get_tree().is_connected("connection_failed", self, "_close_network"):
|
||||
get_tree().disconnect("connection_failed", self, "_close_network")
|
||||
get_tree().disconnect(&"connection_failed", self._close_network)
|
||||
if get_tree().is_connected("connected_to_server", self, "_connected"):
|
||||
get_tree().disconnect("connected_to_server", self, "_connected")
|
||||
get_tree().disconnect(&"connected_to_server", self._connected)
|
||||
stop_game()
|
||||
$AcceptDialog.show_modal()
|
||||
$AcceptDialog.get_close_button().grab_focus()
|
||||
@@ -71,8 +71,8 @@ func _peer_disconnected(id):
|
||||
|
||||
func _on_Host_pressed():
|
||||
peer = WebSocketServer.new()
|
||||
peer.listen(DEF_PORT, PoolStringArray(["ludus"]), true)
|
||||
get_tree().connect("server_disconnected", self, "_close_network")
|
||||
peer.listen(DEF_PORT, PackedStringArray(["ludus"]), true)
|
||||
get_tree().connect(&"server_disconnected", self._close_network)
|
||||
get_tree().set_network_peer(peer)
|
||||
_game.add_player(1, _name_edit.text)
|
||||
start_game()
|
||||
@@ -84,8 +84,8 @@ func _on_Disconnect_pressed():
|
||||
|
||||
func _on_Connect_pressed():
|
||||
peer = WebSocketClient.new()
|
||||
peer.connect_to_url("ws://" + _host_edit.text + ":" + str(DEF_PORT), PoolStringArray([PROTO_NAME]), true)
|
||||
get_tree().connect("connection_failed", self, "_close_network")
|
||||
get_tree().connect("connected_to_server", self, "_connected")
|
||||
peer.connect_to_url("ws://" + _host_edit.text + ":" + str(DEF_PORT), PackedStringArray([PROTO_NAME]), true)
|
||||
get_tree().connect(&"connection_failed", self._close_network)
|
||||
get_tree().connect(&"connected_to_server", self._connected)
|
||||
get_tree().set_network_peer(peer)
|
||||
start_game()
|
||||
|
||||
Reference in New Issue
Block a user