fully sync player movements over network
This commit is contained in:
57
scenes/GUI/MAIN.tscn
Normal file
57
scenes/GUI/MAIN.tscn
Normal file
@@ -0,0 +1,57 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://3o430r2kys4k"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/GUI/main.gd" id="1_i8nr4"]
|
||||
|
||||
[node name="MAIN" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_i8nr4")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -198.0
|
||||
offset_top = -104.0
|
||||
offset_right = 199.0
|
||||
offset_bottom = 64.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 2
|
||||
|
||||
[node name="Start" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Start Game"
|
||||
|
||||
[node name="ModsMenu" type="MenuButton" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Select Mod"
|
||||
flat = false
|
||||
item_count = 2
|
||||
popup/item_0/text = "test1"
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = "test2"
|
||||
popup/item_1/id = 1
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 10
|
||||
|
||||
[node name="SettingsButton" type="Button" parent="VBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Game Settings"
|
||||
icon_alignment = 1
|
||||
|
||||
[node name="ExitButton" type="Button" parent="VBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Exit"
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Start" to="." method="_on_start_pressed"]
|
||||
25
scenes/GUI/MainMenu.gd
Normal file
25
scenes/GUI/MainMenu.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends Control
|
||||
|
||||
@onready var game = get_tree().get_current_scene() as Game
|
||||
@onready var previous = $MAIN
|
||||
@onready var current = $MAIN
|
||||
|
||||
func _on_main_start_game():
|
||||
previous = current
|
||||
current = $"START GAME"
|
||||
$"START GAME".show()
|
||||
|
||||
func back():
|
||||
current.hide()
|
||||
previous.show()
|
||||
var tmp = current
|
||||
current = previous
|
||||
previous = tmp
|
||||
|
||||
func _on_start_game_start_game():
|
||||
game.load_map()
|
||||
self.hide()
|
||||
|
||||
func _on_start_game_back():
|
||||
previous = $MAIN
|
||||
back()
|
||||
62
scenes/GUI/START_GAME.tscn
Normal file
62
scenes/GUI/START_GAME.tscn
Normal file
@@ -0,0 +1,62 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://d0kkhtesg83g"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/GUI/start_game.gd" id="1_amknd"]
|
||||
|
||||
[node name="START GAME" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_amknd")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -198.0
|
||||
offset_top = -104.0
|
||||
offset_right = 199.0
|
||||
offset_bottom = 64.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="HostContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 2
|
||||
|
||||
[node name="HostButton" type="Button" parent="VBoxContainer/HostContainer"]
|
||||
layout_mode = 2
|
||||
text = "Host"
|
||||
|
||||
[node name="JoinContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 2
|
||||
|
||||
[node name="IPAdress" type="TextEdit" parent="VBoxContainer/JoinContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 13
|
||||
placeholder_text = "localhost"
|
||||
|
||||
[node name="JoinButton" type="Button" parent="VBoxContainer/JoinContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 0
|
||||
text = "Join
|
||||
"
|
||||
|
||||
[node name="BackContainer" type="VBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="BackButton" type="Button" parent="VBoxContainer/BackContainer"]
|
||||
layout_mode = 2
|
||||
text = "Back"
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/HostContainer/HostButton" to="." method="_on_host_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/JoinContainer/JoinButton" to="." method="_on_join_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/BackContainer/BackButton" to="." method="_on_back_button_pressed"]
|
||||
7
scenes/GUI/main.gd
Normal file
7
scenes/GUI/main.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
extends Control
|
||||
|
||||
signal start_game;
|
||||
|
||||
func _on_start_pressed():
|
||||
start_game.emit()
|
||||
hide()
|
||||
27
scenes/GUI/start_game.gd
Normal file
27
scenes/GUI/start_game.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends Control
|
||||
|
||||
@onready var IPAdress_Field = $VBoxContainer/JoinContainer/IPAdress as TextEdit
|
||||
signal start_game
|
||||
signal back
|
||||
|
||||
func _on_join_button_pressed():
|
||||
if not try_connection():
|
||||
return
|
||||
Network.start_network(false, IPAdress_Field.text)
|
||||
start_game.emit()
|
||||
|
||||
|
||||
func try_connection():
|
||||
if IPAdress_Field.text.is_empty():
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
func _on_host_button_pressed():
|
||||
Network.start_network(true)
|
||||
start_game.emit()
|
||||
|
||||
|
||||
func _on_back_button_pressed():
|
||||
hide()
|
||||
back.emit()
|
||||
5
scenes/map/EntitySpawner.gd
Normal file
5
scenes/map/EntitySpawner.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
extends MultiplayerSpawner
|
||||
|
||||
|
||||
func _spawn_custom(data):
|
||||
return
|
||||
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://8g7w4uv2xsck"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://8g7w4uv2xsck"]
|
||||
|
||||
[ext_resource type="Script" path="res://Game.gd" id="1_71dcv"]
|
||||
[ext_resource type="PackedScene" uid="uid://dsnlwjofq6psf" path="res://scenes/GUI/Main Menu.tscn" id="2_448f8"]
|
||||
[ext_resource type="Script" path="res://scenes/map/EntitySpawner.gd" id="3_i5esv"]
|
||||
|
||||
[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_2n8qo"]
|
||||
|
||||
@@ -34,6 +35,10 @@ environment = SubResource("Environment_oqaam")
|
||||
|
||||
[node name="Networking" type="Node" parent="."]
|
||||
|
||||
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="Networking"]
|
||||
[node name="PlayerSpawner" type="MultiplayerSpawner" parent="Networking"]
|
||||
_spawnable_scenes = PackedStringArray("res://entities/Player.tscn")
|
||||
spawn_path = NodePath("../..")
|
||||
spawn_path = NodePath("..")
|
||||
|
||||
[node name="EntitySpawner" type="MultiplayerSpawner" parent="Networking"]
|
||||
spawn_path = NodePath("..")
|
||||
script = ExtResource("3_i5esv")
|
||||
|
||||
83
scenes/map/test_map_gd.tscn
Normal file
83
scenes/map/test_map_gd.tscn
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user