diff --git a/Scenes/RootNode.tscn b/Scenes/RootNode.tscn new file mode 100644 index 0000000..70d3fda --- /dev/null +++ b/Scenes/RootNode.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Scripts/RootNode.gd" type="Script" id=1] + +[node name="RootNode" type="Node"] +script = ExtResource( 1 ) + +[node name="Lobby" type="Control" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="IPLineEdit" type="LineEdit" parent="Lobby"] +anchor_left = 0.5 +anchor_top = 0.3 +anchor_right = 0.5 +anchor_bottom = 0.3 +margin_left = -100.0 +margin_right = 100.0 +margin_bottom = 25.0 +placeholder_text = "Enter IP Address of Server" + +[node name="StartButton" type="Button" parent="Lobby"] +anchor_left = 0.5 +anchor_top = 0.3 +anchor_right = 0.5 +anchor_bottom = 0.3 +margin_left = -40.0 +margin_top = 40.0 +margin_right = 40.0 +margin_bottom = 25.0 +text = "Start" +__meta__ = { +"_edit_use_anchors_": false +} +[connection signal="pressed" from="Lobby/StartButton" to="." method="_on_StartButton_pressed"] diff --git a/Scripts/RootNode.gd b/Scripts/RootNode.gd new file mode 100644 index 0000000..19da34c --- /dev/null +++ b/Scripts/RootNode.gd @@ -0,0 +1,28 @@ +extends Node + + +const PORT : int = 9374 + + + +func _ready() -> void: + get_tree().connect("connected_to_server", self, "_connected_to_server") + get_tree().connect("server_disconnected", self, "_server_disconnected") + get_tree().connect("connection_failed", self, "_connection_failed") + +func _connected_to_server() -> void: + print("Connected to server") # Let the server know all about us (eg name) + +func _server_disconnected() -> void: + print("Disconnected from server") # Kick us out the game and bring back the lobby (if applicable) + +func _connection_failed() -> void: + print("Connection Error") + + + +func _on_StartButton_pressed() -> void: + var ip_addr : String = $Lobby/IPLineEdit.text + var peer : NetworkedMultiplayerENet = NetworkedMultiplayerENet.new() + peer.create_client(ip_addr, PORT) + get_tree().set_network_peer(peer) diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..2e42096 Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..96cbf46 --- /dev/null +++ b/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..2f7e9a3 --- /dev/null +++ b/project.godot @@ -0,0 +1,24 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +_global_script_classes=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="Client" +run/main_scene="res://Scenes/RootNode.tscn" +config/icon="res://icon.png" + +[rendering] + +environment/default_environment="res://default_env.tres"