Skip to content

Commit f2e7f1d

Browse files
authored
Merge pull request #10 from ValorZard/add-net-pong
add net pong
2 parents 3f50c86 + db8627e commit f2e7f1d

26 files changed

+925
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resolver = "2"
33
members = [
44
"dodge-the-creeps/rust",
55
"hot-reload/rust",
6+
"net-pong/rust",
67
"squash-the-creeps/rust"
78
]
89

net-pong/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Asdrome
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

net-pong/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Godot Rust Multiplayer Pong
2+
based on https://godotengine.org/asset-library/asset/2798
3+
source code: https://github.com/godotengine/godot-demo-projects/tree/4.3/networking/multiplayer_pong
4+
5+
## License
6+
7+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
8+
9+
The godot-rust Ferris icon was obtained from [their repository](https://github.com/godot-rust/assets) and its licence's details are explained [here](https://github.com/godot-rust/assets/blob/master/asset-licenses.md).
10+
11+
Shield: [![CC BY 4.0][cc-by-shield]][cc-by]
12+
13+
This work is licensed under a
14+
[Creative Commons Attribution 4.0 International License][cc-by].
15+
16+
[![CC BY 4.0][cc-by-image]][cc-by]
17+
18+
[cc-by]: http://creativecommons.org/licenses/by/4.0/
19+
[cc-by-image]: https://i.creativecommons.org/l/by/4.0/88x31.png
20+
[cc-by-shield]: https://img.shields.io/badge/License-CC%20BY%204.0-lightgrey.svg
21+
22+
## Acknowledgments
23+
24+
- [Godot Engine](https://godotengine.org/)
25+
- [Godot Rust](https://github.com/godot-rust/gdext) for their fantastic work on integrating Rust with Godot.

net-pong/godot/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Godot 4+ specific ignores
2+
.godot/
3+
/android/

net-pong/godot/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Pong Multiplayer
2+
3+
A multiplayer implementation of the classic pong game.
4+
One of the players should press **Host**, while the other
5+
should type in the host's IP address and press **Join**.
6+
7+
Language: GDScript
8+
9+
Renderer: Compatibility
10+
11+
Note: The non-multiplayer version is available [here](https://github.com/godotengine/godot-demo-projects/tree/master/2d/pong).
12+
13+
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2798
14+
15+
## Screenshots
16+
17+
![Screenshot](screenshots/pong_multiplayer.png)

net-pong/godot/ball.png

115 Bytes
Loading

net-pong/godot/ball.tscn

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[gd_scene load_steps=3 format=3 uid="uid://bjmldn1x3lpa"]
2+
3+
[ext_resource type="Texture2D" uid="uid://i1imfdcn7ui" path="res://ball.png" id="2"]
4+
5+
[sub_resource type="CircleShape2D" id="1"]
6+
radius = 5.11969
7+
8+
[node name="Ball" type="Ball"]
9+
10+
[node name="Sprite2D" type="Sprite2D" parent="."]
11+
texture = ExtResource("2")
12+
13+
[node name="Shape3D" type="CollisionShape2D" parent="."]
14+
shape = SubResource("1")

net-pong/godot/godot-rust.png

13.4 KB
Loading

net-pong/godot/icon.webp

1.78 KB
Loading

net-pong/godot/lobby.tscn

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
[gd_scene format=3 uid="uid://f85s2avde6r4"]
2+
3+
[node name="Lobby" type="Control"]
4+
layout_mode = 3
5+
anchors_preset = 8
6+
anchor_left = 0.5
7+
anchor_top = 0.5
8+
anchor_right = 0.5
9+
anchor_bottom = 0.5
10+
offset_left = -320.0
11+
offset_top = -200.0
12+
offset_right = 320.0
13+
offset_bottom = 200.0
14+
grow_horizontal = 2
15+
grow_vertical = 2
16+
size_flags_horizontal = 2
17+
size_flags_vertical = 2
18+
19+
[node name="Title" type="Label" parent="."]
20+
layout_mode = 1
21+
anchors_preset = 8
22+
anchor_left = 0.5
23+
anchor_top = 0.5
24+
anchor_right = 0.5
25+
anchor_bottom = 0.5
26+
offset_left = -110.0
27+
offset_top = -156.0
28+
offset_right = 110.0
29+
offset_bottom = -116.0
30+
grow_horizontal = 2
31+
grow_vertical = 2
32+
size_flags_horizontal = 2
33+
size_flags_vertical = 0
34+
theme_override_font_sizes/font_size = 32
35+
text = "Multiplayer Pong"
36+
horizontal_alignment = 1
37+
vertical_alignment = 1
38+
39+
[node name="LobbyPanel" type="Lobby" parent="." node_paths=PackedStringArray("address", "host_button", "join_button", "status_ok", "status_fail", "port_forward_label", "find_public_ip_button")]
40+
address = NodePath("Address")
41+
host_button = NodePath("HostButton")
42+
join_button = NodePath("JoinButton")
43+
status_ok = NodePath("StatusOk")
44+
status_fail = NodePath("StatusFail")
45+
port_forward_label = NodePath("PortForward")
46+
find_public_ip_button = NodePath("FindPublicIP")
47+
layout_mode = 1
48+
anchors_preset = 8
49+
anchor_left = 0.5
50+
anchor_top = 0.5
51+
anchor_right = 0.5
52+
anchor_bottom = 0.5
53+
offset_left = -110.0
54+
offset_top = -73.0
55+
offset_right = 110.0
56+
offset_bottom = 73.0
57+
grow_horizontal = 2
58+
grow_vertical = 2
59+
size_flags_horizontal = 2
60+
size_flags_vertical = 2
61+
62+
[node name="AddressLabel" type="Label" parent="LobbyPanel"]
63+
layout_mode = 0
64+
offset_left = 10.0
65+
offset_top = 6.0
66+
offset_right = 77.0
67+
offset_bottom = 29.0
68+
size_flags_horizontal = 2
69+
size_flags_vertical = 0
70+
text = "Address:"
71+
72+
[node name="Address" type="LineEdit" parent="LobbyPanel"]
73+
layout_mode = 0
74+
offset_left = 10.0
75+
offset_top = 37.0
76+
offset_right = 210.0
77+
offset_bottom = 68.0
78+
size_flags_horizontal = 2
79+
size_flags_vertical = 2
80+
text = "127.0.0.1"
81+
82+
[node name="HostButton" type="Button" parent="LobbyPanel"]
83+
layout_mode = 0
84+
offset_left = 10.0
85+
offset_top = 76.0
86+
offset_right = 90.0
87+
offset_bottom = 107.0
88+
size_flags_horizontal = 2
89+
size_flags_vertical = 2
90+
text = "Host"
91+
92+
[node name="JoinButton" type="Button" parent="LobbyPanel"]
93+
layout_mode = 0
94+
offset_left = 130.0
95+
offset_top = 76.0
96+
offset_right = 210.0
97+
offset_bottom = 107.0
98+
size_flags_horizontal = 2
99+
size_flags_vertical = 2
100+
text = "Join"
101+
102+
[node name="StatusOk" type="Label" parent="LobbyPanel"]
103+
layout_mode = 0
104+
offset_left = 10.0
105+
offset_top = 114.0
106+
offset_right = 210.0
107+
offset_bottom = 137.0
108+
size_flags_horizontal = 2
109+
size_flags_vertical = 0
110+
horizontal_alignment = 1
111+
112+
[node name="StatusFail" type="Label" parent="LobbyPanel"]
113+
modulate = Color(1, 0.427451, 0.345098, 1)
114+
layout_mode = 0
115+
offset_left = 10.0
116+
offset_top = 114.0
117+
offset_right = 210.0
118+
offset_bottom = 137.0
119+
size_flags_horizontal = 2
120+
size_flags_vertical = 0
121+
horizontal_alignment = 1
122+
123+
[node name="PortForward" type="Label" parent="LobbyPanel"]
124+
visible = false
125+
layout_mode = 1
126+
anchors_preset = 8
127+
anchor_left = 0.5
128+
anchor_top = 0.5
129+
anchor_right = 0.5
130+
anchor_bottom = 0.5
131+
offset_left = -278.0
132+
offset_top = 91.0
133+
offset_right = 25.0
134+
offset_bottom = 166.0
135+
grow_horizontal = 2
136+
grow_vertical = 2
137+
text = "If you want non-LAN clients to connect,
138+
make sure the port 8910 in UDP
139+
is forwarded on your router."
140+
141+
[node name="FindPublicIP" type="LinkButton" parent="LobbyPanel"]
142+
visible = false
143+
layout_mode = 1
144+
anchors_preset = 8
145+
anchor_left = 0.5
146+
anchor_top = 0.5
147+
anchor_right = 0.5
148+
anchor_bottom = 0.5
149+
offset_left = 61.0
150+
offset_top = 118.0
151+
offset_right = 269.0
152+
offset_bottom = 141.0
153+
grow_horizontal = 2
154+
grow_vertical = 2
155+
text = "Find your public IP address"
156+
157+
[connection signal="pressed" from="LobbyPanel/HostButton" to="LobbyPanel" method="_on_host_pressed"]
158+
[connection signal="pressed" from="LobbyPanel/JoinButton" to="LobbyPanel" method="_on_join_pressed"]
159+
[connection signal="pressed" from="LobbyPanel/FindPublicIP" to="LobbyPanel" method="_on_find_public_ip_pressed"]

0 commit comments

Comments
 (0)