commit a4d1aa7c7dddb734434bdbe24a1a2e8c192df9dc from: Omar Polo date: Fri Jul 22 21:30:42 2022 UTC +menu commit - 198fcbc902b9533dd537679f08f4622831ae80a1 commit + a4d1aa7c7dddb734434bdbe24a1a2e8c192df9dc blob - d53ad97046d21406515beef32bcca8e9270cb372 blob + f26f4e52a14df63afeb4f2e4eac4468fb0d718e8 --- project.godot +++ project.godot @@ -11,6 +11,7 @@ config_version=4 [application] config/name="Ciess 2022" +run/main_scene="res://src/menu.tscn" config/icon="res://icon.png" [physics] blob - /dev/null blob + c72ef621c66254dfada248a3fc255269ec8d0f09 (mode 644) --- /dev/null +++ src/menu.gd @@ -0,0 +1,37 @@ +extends Node2D + + +const MAX_PLAYERS = 2 +const SERVER_PORT = 2022 + + +func _ready() -> void: + print("hello, world") + + +func _on_serverz_click() -> void: + var peer := NetworkedMultiplayerENet.new() + var err := peer.create_server(SERVER_PORT, MAX_PLAYERS) + if err != OK: + print("WOOOOPS, failed with error ", err) + return + get_tree().network_peer = peer + goto_board() + + +func _on_clientz_click() -> void: + var peer := NetworkedMultiplayerENet.new() + var err := peer.create_client($ipaddr.text, SERVER_PORT) + if err != OK: + print("WOOOOPS, failed with error ", err) + return + get_tree().network_peer = peer + goto_board() + + +func goto_board() -> void: + var board := preload("res://src/board.tscn") + var err := get_tree().change_scene_to(board) + if err != OK: + print("WOOOPS, failed with err ", err) + return blob - /dev/null blob + ab18aceaf201668afaa357d3d9b3221334dc37eb (mode 644) --- /dev/null +++ src/menu.tscn @@ -0,0 +1,44 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/menu.gd" type="Script" id=1] + +[node name="menu" type="Node2D"] +script = ExtResource( 1 ) + +[node name="serverz" type="Button" parent="."] +margin_left = 503.0 +margin_top = 43.0 +margin_right = 588.0 +margin_bottom = 63.0 +text = "start server" + +[node name="label francesco 2" type="Label" parent="."] +margin_left = 508.0 +margin_top = 101.0 +margin_right = 591.0 +margin_bottom = 115.0 +text = "--- oppure ---" + +[node name="clientz" type="Button" parent="."] +margin_left = 489.0 +margin_top = 151.0 +margin_right = 613.0 +margin_bottom = 171.0 +text = "connect to server" + +[node name="ipaddr" type="LineEdit" parent="."] +margin_left = 450.0 +margin_top = 189.0 +margin_right = 799.0 +margin_bottom = 213.0 +text = "10.0.0.2" + +[node name="label francesco" type="Label" parent="."] +margin_left = 367.0 +margin_top = 194.0 +margin_right = 446.0 +margin_bottom = 208.0 +text = "IP ADDRESS:" + +[connection signal="button_down" from="serverz" to="." method="_on_serverz_click"] +[connection signal="button_down" from="clientz" to="." method="_on_clientz_click"]