mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-16 13:30:07 +01:00
Update multiplayer pong to godot 4 beta 5
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://i1imfdcn7ui"
|
||||
path="res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,26 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://ball.png"
|
||||
dest_files=["res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"]
|
||||
dest_files=["res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bjmldn1x3lpa"]
|
||||
|
||||
[ext_resource path="res://logic/ball.gd" type="Script" id=1]
|
||||
[ext_resource path="res://ball.png" type="Texture2D" id=2]
|
||||
[ext_resource type="Script" path="res://logic/ball.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://i1imfdcn7ui" path="res://ball.png" id="2"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
[sub_resource type="CircleShape2D" id="1"]
|
||||
radius = 5.11969
|
||||
|
||||
[node name="Ball" type="Area2D"]
|
||||
script = ExtResource( 1 )
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
texture = ExtResource("2")
|
||||
|
||||
[node name="Shape3D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
shape = SubResource("1")
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://djyutu2uyhiw7"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,26 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://f85s2avde6r4"]
|
||||
|
||||
[ext_resource path="res://logic/lobby.gd" type="Script" id=1]
|
||||
[ext_resource type="Script" path="res://logic/lobby.gd" id="1"]
|
||||
|
||||
[node name="Lobby" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
@@ -11,13 +13,13 @@ offset_left = -320.0
|
||||
offset_top = -200.0
|
||||
offset_right = 320.0
|
||||
offset_bottom = 200.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Title" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 210.0
|
||||
offset_top = 40.0
|
||||
offset_right = 430.0
|
||||
@@ -25,19 +27,19 @@ offset_bottom = 80.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "Multiplayer Pong"
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="LobbyPanel" type="Panel" parent="."]
|
||||
layout_mode = 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 )
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="AddressLabel" type="Label" parent="LobbyPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 10.0
|
||||
offset_right = 62.0
|
||||
@@ -47,6 +49,7 @@ size_flags_vertical = 0
|
||||
text = "Address"
|
||||
|
||||
[node name="Address" type="LineEdit" parent="LobbyPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 30.0
|
||||
offset_right = 210.0
|
||||
@@ -56,6 +59,7 @@ size_flags_vertical = 2
|
||||
text = "127.0.0.1"
|
||||
|
||||
[node name="HostButton" type="Button" parent="LobbyPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 60.0
|
||||
offset_right = 90.0
|
||||
@@ -65,6 +69,7 @@ size_flags_vertical = 2
|
||||
text = "Host"
|
||||
|
||||
[node name="JoinButton" type="Button" parent="LobbyPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 130.0
|
||||
offset_top = 60.0
|
||||
offset_right = 210.0
|
||||
@@ -74,50 +79,42 @@ size_flags_vertical = 2
|
||||
text = "Join"
|
||||
|
||||
[node name="StatusOk" type="Label" parent="LobbyPanel"]
|
||||
layout_mode = 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)
|
||||
align = 1
|
||||
|
||||
[node name="StatusFail" type="Label" parent="LobbyPanel"]
|
||||
layout_mode = 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)
|
||||
align = 1
|
||||
|
||||
[node name="PortForward" type="Label" parent="LobbyPanel"]
|
||||
visible = false
|
||||
layout_mode = 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
|
||||
is forwarded on your router."
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
is forwarded checked your router."
|
||||
|
||||
[node name="FindPublicIP" type="LinkButton" parent="LobbyPanel"]
|
||||
visible = false
|
||||
layout_mode = 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
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="LobbyPanel/HostButton" to="LobbyPanel" method="_on_host_pressed"]
|
||||
[connection signal="pressed" from="LobbyPanel/JoinButton" to="LobbyPanel" method="_on_join_pressed"]
|
||||
|
||||
@@ -21,15 +21,15 @@ func _process(delta):
|
||||
if (ball_pos.y < 0 and direction.y < 0) or (ball_pos.y > _screen_size.y and direction.y > 0):
|
||||
direction.y = -direction.y
|
||||
|
||||
if is_network_master():
|
||||
if is_multiplayer_authority():
|
||||
# Only the master will decide when the ball is out in
|
||||
# the left side (it's own side). This makes the game
|
||||
# playable even if latency is high and ball is going
|
||||
# fast. Otherwise ball might be out in the other
|
||||
# player's screen but not this one.
|
||||
if ball_pos.x < 0:
|
||||
get_parent().rpc("update_score", false)
|
||||
rpc("_reset_ball", false)
|
||||
get_parent().update_score.rpc(false)
|
||||
_reset_ball.rpc(false)
|
||||
else:
|
||||
# Only the puppet will decide when the ball is out in
|
||||
# the right side, which is it's own side. This makes
|
||||
@@ -37,11 +37,11 @@ func _process(delta):
|
||||
# is going fast. Otherwise ball might be out in the
|
||||
# other player's screen but not this one.
|
||||
if ball_pos.x > _screen_size.x:
|
||||
get_parent().rpc("update_score", true)
|
||||
rpc("_reset_ball", true)
|
||||
get_parent().update_score.rpc(true)
|
||||
_reset_ball.rpc(true)
|
||||
|
||||
|
||||
remotesync func bounce(left, random):
|
||||
@rpc(any_peer, call_local) func bounce(left, random):
|
||||
# Using sync because both players can make it bounce.
|
||||
if left:
|
||||
direction.x = abs(direction.x)
|
||||
@@ -53,11 +53,11 @@ remotesync func bounce(left, random):
|
||||
direction = direction.normalized()
|
||||
|
||||
|
||||
remotesync func stop():
|
||||
@rpc(any_peer, call_local) func stop():
|
||||
stopped = true
|
||||
|
||||
|
||||
remotesync func _reset_ball(for_left):
|
||||
@rpc(any_peer, call_local) func _reset_ball(for_left):
|
||||
position = _screen_size / 2
|
||||
if for_left:
|
||||
direction = Vector2.LEFT
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Control
|
||||
|
||||
# Default game server port. Can be any number between 1024 and 49151.
|
||||
# Not on the list of registered or common ports as of November 2020:
|
||||
# Not checked the list of registered or common ports as of November 2020:
|
||||
# https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
|
||||
const DEFAULT_PORT = 8910
|
||||
|
||||
@@ -17,11 +17,11 @@ 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)
|
||||
multiplayer.connect(&"peer_connected", self._player_connected)
|
||||
multiplayer.connect(&"peer_disconnected", self._player_disconnected)
|
||||
multiplayer.connect(&"connected_to_server", self._connected_ok)
|
||||
multiplayer.connect(&"connection_failed", self._connected_fail)
|
||||
multiplayer.connect(&"server_disconnected", self._server_disconnected)
|
||||
|
||||
#### Network callbacks from SceneTree ####
|
||||
|
||||
@@ -30,14 +30,14 @@ func _player_connected(_id):
|
||||
# Someone connected, start the game!
|
||||
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",Callable(self._end_game).bind(CONNECT_DEFERRED))
|
||||
|
||||
get_tree().get_root().add_child(pong)
|
||||
hide()
|
||||
|
||||
|
||||
func _player_disconnected(_id):
|
||||
if get_tree().is_network_server():
|
||||
if multiplayer.is_server():
|
||||
_end_game("Client disconnected")
|
||||
else:
|
||||
_end_game("Server disconnected")
|
||||
@@ -52,7 +52,7 @@ func _connected_ok():
|
||||
func _connected_fail():
|
||||
_set_status("Couldn't connect", false)
|
||||
|
||||
get_tree().set_network_peer(null) # Remove peer.
|
||||
multiplayer.set_multiplayer_peer(null) # Remove peer.
|
||||
host_button.set_disabled(false)
|
||||
join_button.set_disabled(false)
|
||||
|
||||
@@ -69,7 +69,7 @@ func _end_game(with_error = ""):
|
||||
get_node(^"/root/Pong").free()
|
||||
show()
|
||||
|
||||
get_tree().set_network_peer(null) # Remove peer.
|
||||
multiplayer.set_multiplayer_peer(null) # Remove peer.
|
||||
host_button.set_disabled(false)
|
||||
join_button.set_disabled(false)
|
||||
|
||||
@@ -87,15 +87,15 @@ func _set_status(text, isok):
|
||||
|
||||
|
||||
func _on_host_pressed():
|
||||
peer = NetworkedMultiplayerENet.new()
|
||||
peer.set_compression_mode(NetworkedMultiplayerENet.COMPRESS_RANGE_CODER)
|
||||
peer = ENetMultiplayerPeer.new()
|
||||
var err = peer.create_server(DEFAULT_PORT, 1) # Maximum of 1 peer, since it's a 2-player game.
|
||||
if err != OK:
|
||||
# Is another server running?
|
||||
_set_status("Can't host, address in use.",false)
|
||||
return
|
||||
peer.get_host().compress(ENetConnection.COMPRESS_RANGE_CODER)
|
||||
|
||||
get_tree().set_network_peer(peer)
|
||||
multiplayer.set_multiplayer_peer(peer)
|
||||
host_button.set_disabled(true)
|
||||
join_button.set_disabled(true)
|
||||
_set_status("Waiting for player...", true)
|
||||
@@ -111,10 +111,10 @@ func _on_join_pressed():
|
||||
_set_status("IP address is invalid", false)
|
||||
return
|
||||
|
||||
peer = NetworkedMultiplayerENet.new()
|
||||
peer.set_compression_mode(NetworkedMultiplayerENet.COMPRESS_RANGE_CODER)
|
||||
peer = ENetMultiplayerPeer.new()
|
||||
peer.create_client(ip, DEFAULT_PORT)
|
||||
get_tree().set_network_peer(peer)
|
||||
peer.get_host().compress(ENetConnection.COMPRESS_RANGE_CODER)
|
||||
multiplayer.set_multiplayer_peer(peer)
|
||||
|
||||
_set_status("Connecting...", true)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ var _you_hidden = false
|
||||
|
||||
func _process(delta):
|
||||
# Is the master of the paddle.
|
||||
if is_network_master():
|
||||
if is_multiplayer_authority():
|
||||
_motion = Input.get_axis(&"move_up", &"move_down")
|
||||
|
||||
if not _you_hidden and _motion != 0:
|
||||
@@ -21,7 +21,7 @@ func _process(delta):
|
||||
|
||||
# Using unreliable to make sure position is updated as fast
|
||||
# as possible, even if one of the calls is dropped.
|
||||
rpc_unreliable("set_pos_and_motion", position, _motion)
|
||||
set_pos_and_motion.rpc(position, _motion)
|
||||
else:
|
||||
if not _you_hidden:
|
||||
_hide_you_label()
|
||||
@@ -33,7 +33,7 @@ func _process(delta):
|
||||
|
||||
|
||||
# Synchronize position and speed to the other peers.
|
||||
puppet func set_pos_and_motion(pos, motion):
|
||||
@rpc(unreliable) func set_pos_and_motion(pos, motion):
|
||||
position = pos
|
||||
_motion = motion
|
||||
|
||||
@@ -44,6 +44,6 @@ func _hide_you_label():
|
||||
|
||||
|
||||
func _on_paddle_area_enter(area):
|
||||
if is_network_master():
|
||||
# Random for new direction generated on each peer.
|
||||
area.rpc("bounce", left, randf())
|
||||
if is_multiplayer_authority():
|
||||
# Random for new direction generated checked each peer.
|
||||
area.bounce.rpc(left, randf())
|
||||
|
||||
@@ -16,18 +16,18 @@ var score_right = 0
|
||||
func _ready():
|
||||
# By default, all nodes in server inherit from master,
|
||||
# while all nodes in clients inherit from puppet.
|
||||
# set_network_master is tree-recursive by default.
|
||||
if get_tree().is_network_server():
|
||||
# set_multiplayer_authority is tree-recursive by default.
|
||||
if multiplayer.is_server():
|
||||
# For the server, give control of player 2 to the other peer.
|
||||
player2.set_network_master(get_tree().get_network_connected_peers()[0])
|
||||
player2.set_multiplayer_authority(multiplayer.get_peers()[0])
|
||||
else:
|
||||
# For the client, give control of player 2 to itself.
|
||||
player2.set_network_master(get_tree().get_network_unique_id())
|
||||
player2.set_multiplayer_authority(multiplayer.get_unique_id())
|
||||
|
||||
print("Unique id: ", get_tree().get_network_unique_id())
|
||||
print("Unique id: ", multiplayer.get_unique_id())
|
||||
|
||||
|
||||
remotesync func update_score(add_to_left):
|
||||
@rpc(any_peer, call_local) func update_score(add_to_left):
|
||||
if add_to_left:
|
||||
score_left += 1
|
||||
score_left_node.set_text(str(score_left))
|
||||
@@ -45,7 +45,7 @@ remotesync func update_score(add_to_left):
|
||||
|
||||
if game_ended:
|
||||
$ExitGame.show()
|
||||
$Ball.rpc("stop")
|
||||
$Ball.stop.rpc()
|
||||
|
||||
|
||||
func _on_exit_game_pressed():
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/paddle.png-0e798fb0912613386507c9904d5cc01a.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bjw2yb853klh2"
|
||||
path="res://.godot/imported/paddle.png-0e798fb0912613386507c9904d5cc01a.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,26 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://paddle.png"
|
||||
dest_files=["res://.godot/imported/paddle.png-0e798fb0912613386507c9904d5cc01a.stex"]
|
||||
dest_files=["res://.godot/imported/paddle.png-0e798fb0912613386507c9904d5cc01a.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cpw46256eirwq"]
|
||||
|
||||
[ext_resource path="res://logic/paddle.gd" type="Script" id=1]
|
||||
[ext_resource path="res://paddle.png" type="Texture2D" id=2]
|
||||
[ext_resource type="Script" path="res://logic/paddle.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://bjw2yb853klh2" path="res://paddle.png" id="2"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
[sub_resource type="CapsuleShape2D" id="1"]
|
||||
radius = 4.78568
|
||||
height = 23.6064
|
||||
|
||||
[node name="Paddle" type="Area2D"]
|
||||
script = ExtResource( 1 )
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
texture = ExtResource("2")
|
||||
|
||||
[node name="Shape3D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
shape = SubResource("1")
|
||||
|
||||
[node name="You" type="Label" parent="."]
|
||||
offset_left = -26.0
|
||||
@@ -24,6 +24,5 @@ offset_bottom = -19.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "You"
|
||||
align = 1
|
||||
|
||||
[connection signal="area_entered" from="." to="." method="_on_paddle_area_enter"]
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://bafoh1ief0147"]
|
||||
|
||||
[ext_resource path="res://logic/pong.gd" type="Script" id=1]
|
||||
[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]
|
||||
[ext_resource type="Script" path="res://logic/pong.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://b10swafhe08oj" path="res://separator.png" id="2"]
|
||||
[ext_resource type="PackedScene" uid="uid://cpw46256eirwq" path="res://paddle.tscn" id="3"]
|
||||
[ext_resource type="PackedScene" uid="uid://bjmldn1x3lpa" path="res://ball.tscn" id="4"]
|
||||
|
||||
[node name="Pong" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
offset_right = 640.0
|
||||
offset_bottom = 400.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.141176, 0.152941, 0.164706, 1)
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Separator" type="Sprite2D" parent="."]
|
||||
position = Vector2(320, 200)
|
||||
texture = ExtResource( 2 )
|
||||
texture = ExtResource("2")
|
||||
|
||||
[node name="Player1" parent="." instance=ExtResource( 3 )]
|
||||
[node name="Player1" parent="." instance=ExtResource("3")]
|
||||
modulate = Color(0, 1, 1, 1)
|
||||
position = Vector2(32.49, 188.622)
|
||||
left = true
|
||||
|
||||
[node name="Player2" parent="." instance=ExtResource( 3 )]
|
||||
[node name="Player2" parent="." instance=ExtResource("3")]
|
||||
modulate = Color(1, 0, 1, 1)
|
||||
position = Vector2(608.88, 188.622)
|
||||
|
||||
[node name="Ball" parent="." instance=ExtResource( 4 )]
|
||||
[node name="Ball" parent="." instance=ExtResource("4")]
|
||||
position = Vector2(320.387, 189.525)
|
||||
|
||||
[node name="ScoreLeft" type="Label" parent="."]
|
||||
@@ -40,7 +39,6 @@ offset_bottom = 30.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "0"
|
||||
align = 1
|
||||
|
||||
[node name="ScoreRight" type="Label" parent="."]
|
||||
offset_left = 360.0
|
||||
@@ -50,7 +48,6 @@ offset_bottom = 30.0
|
||||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 0
|
||||
text = "0"
|
||||
align = 1
|
||||
|
||||
[node name="WinnerLeft" type="Label" parent="."]
|
||||
visible = false
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
@@ -15,6 +15,7 @@ config/description="A multiplayer demo of the classical pong game.
|
||||
One of the players should press 'host', while the
|
||||
other should select the address and press 'join'."
|
||||
run/main_scene="res://lobby.tscn"
|
||||
config/features=PackedStringArray("4.0")
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[debug]
|
||||
@@ -23,11 +24,12 @@ gdscript/warnings/return_value_discarded=false
|
||||
|
||||
[display]
|
||||
|
||||
window/size/width=640
|
||||
window/size/height=400
|
||||
window/dpi/allow_hidpi=true
|
||||
window/size/viewport_width=640
|
||||
window/size/viewport_height=400
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="expand"
|
||||
window/size/width=640
|
||||
window/size/height=400
|
||||
stretch_2d=true
|
||||
|
||||
[gdnative]
|
||||
@@ -38,20 +40,20 @@ singletons=[]
|
||||
|
||||
move_down={
|
||||
"deadzone": 0.5,
|
||||
"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)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_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,"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)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_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,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_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,"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)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_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,"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)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_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,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b10swafhe08oj"
|
||||
path="res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,26 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://separator.png"
|
||||
dest_files=["res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.stex"]
|
||||
dest_files=["res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
Reference in New Issue
Block a user