diff --git a/Scenes/RootNode.tscn b/Scenes/RootNode.tscn new file mode 100644 index 0000000..e752e34 --- /dev/null +++ b/Scenes/RootNode.tscn @@ -0,0 +1,6 @@ +[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 ) diff --git a/Scripts/RootNode.gd b/Scripts/RootNode.gd new file mode 100644 index 0000000..3243705 --- /dev/null +++ b/Scripts/RootNode.gd @@ -0,0 +1,30 @@ +extends Node + + +const MAX_PLAYERS : int = 2 +const PORT : int = 9374 + +var ids = [] + +func _ready() -> void: + var peer : NetworkedMultiplayerENet = NetworkedMultiplayerENet.new() + peer.create_server( PORT, MAX_PLAYERS ) + get_tree().set_network_peer( peer ) + + get_tree().connect("network_peer_connected", self, "_peer_connected") + get_tree().connect("network_peer_disconnected", self, "_peer_disconnected") + +func _peer_connected(id : int) -> void: + if not id: + return + ids.append(id) + print("Player has connected with id " + String(id)) + # TODO: When we reach max players -> start the game + +func _peer_disconnected(id : int) -> void: + ids.erase(id) + print("Player has disconnected with id " + String(id)) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass 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..b277412 --- /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="Server" +run/main_scene="res://Scenes/RootNode.tscn" +config/icon="res://icon.png" + +[rendering] + +environment/default_environment="res://default_env.tres"