Project reorganization

Reorganized the project so it's a little less all over the place. For example, world scenes are now in scenes/world. I also moved all scripts to the script directory.
This commit is contained in:
Anthony Foxclaw 2020-06-28 14:58:49 -04:00
parent 6ce7d58163
commit dbac16804c
7 changed files with 35 additions and 44 deletions

50
scripts/menu.gd Normal file
View file

@ -0,0 +1,50 @@
extends Control
var host_port = 2675
var host_playermax = 2
var ip = "127.0.0.1"
var port = 2670
# Called when the node enters the scene tree for the first time.
func _ready():
if OS.has_environment("USERNAME"):
$GeneralPanel/player_name.text = OS.get_environment("USERNAME")
else:
var desktop_path = OS.get_system_dir(0).replace("\\", "/").split("/")
$GeneralPanel/player_name.text = desktop_path[desktop_path.size() - 2]
func _on_singleplayer_button_up():
var _letsgo = get_tree().change_scene("res://scenes/world/World.tscn")
func _on_JoinGameBtn_button_up():
ip = $JoinPanel/join_ip
port = $JoinPanel/join_port
print("Netplay - Attempting to join game at IP ",ip," via port ",port)
join_game()
func _on_HostGameBtn_button_up():
var host_port = $HostPanel/host_port.value
print("Netplay - Attempting to host game on port ",host_port,"...")
host_game(host_port)
func host_game(port):
var maxplayers = $HostPanel/playercount.value
var host = NetworkedMultiplayerENet.new()
print("Netplay - Returned: ",host)
host.create_server(port, maxplayers) # ports, maxplayers
get_tree().set_network_peer(host)
print("Netplay - Hosting on port ",port,". Max players: ",maxplayers)
print("Netplay - Are you the server ... ",get_tree().is_network_server())
$HostPanel/HostGameBtn.disabled = 1
$HostPanel/HostGameBtn.hint_tooltip = "Cannot start another server, Server already started."
$JoinPanel/JoinGameBtn.disabled = 1
$JoinPanel/JoinGameBtn.hint_tooltip = "Cannot join another server, Server already started."
#Goto a lobby instance
func join_game():
var host = NetworkedMultiplayerENet.new()
host.create_client(ip, port)
get_tree().set_network_peer(host)
print("Maybe it joined...?")

View file

@ -9,8 +9,7 @@ var motion = Vector2()
var spawned = false
func _ready():
$SndSpawn.play(0);
pass
$SndSpawn.play(0)
func _physics_process(delta):
@ -40,4 +39,3 @@ func _physics_process(delta):
#print(motion)
motion = move_and_slide(motion, UP)
pass