Compare commits

..

4 commits

Author SHA1 Message Date
f298ca909c Forward progress on joining sessions. Pre-game lobby created. 2020-06-28 20:51:27 -05:00
f9a788d7db Merge pull request 'Project reorganization' (#9) from tonytins/PoloTins:project/reorganization into master
Reviewed-on: drraccoon/GD-Polo#9
2020-06-28 20:19:59 -04:00
Anthony Foxclaw
dbac16804c 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.
2020-06-28 14:58:49 -04:00
aa9a5c824c Merge pull request 'Decoupled player and background scenes' (#2) from tonytins/PoloGD:master into master
Reviewed-on: drraccoon/Polo-Godot#2

Looks great. I was meaning to do this but it was low priority for myself. Though this eliminates the need to do that now.

Thanks!
2020-06-26 18:32:24 -04:00
8 changed files with 187 additions and 103 deletions

View file

@ -40,16 +40,21 @@
[sub_resource type="SpriteFrames" id=1] [sub_resource type="SpriteFrames" id=1]
animations = [ { animations = [ {
"frames": [ ExtResource( 33 ), ExtResource( 23 ), ExtResource( 15 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ) ],
"loop": true,
"name": "Idle",
"speed": 20.0
}, {
"frames": [ ExtResource( 14 ), ExtResource( 11 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 29 ), ExtResource( 31 ), ExtResource( 19 ), ExtResource( 13 ), ExtResource( 24 ), ExtResource( 6 ) ], "frames": [ ExtResource( 14 ), ExtResource( 11 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 29 ), ExtResource( 31 ), ExtResource( 19 ), ExtResource( 13 ), ExtResource( 24 ), ExtResource( 6 ) ],
"loop": false, "loop": false,
"name": "Spawn", "name": "Spawn",
"speed": 5.0 "speed": 5.0
}, { }, {
"frames": [ ExtResource( 9 ), ExtResource( 27 ), ExtResource( 26 ), ExtResource( 12 ), ExtResource( 35 ), ExtResource( 34 ), ExtResource( 36 ), ExtResource( 10 ), ExtResource( 30 ), ExtResource( 28 ), ExtResource( 21 ), ExtResource( 32 ), ExtResource( 8 ), ExtResource( 18 ) ],
"loop": true,
"name": "Warp",
"speed": 20.0
}, {
"frames": [ ExtResource( 33 ), ExtResource( 23 ), ExtResource( 15 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ), ExtResource( 33 ) ],
"loop": true,
"name": "Idle",
"speed": 20.0
}, {
"frames": [ ExtResource( 5 ) ], "frames": [ ExtResource( 5 ) ],
"loop": true, "loop": true,
"name": "Fall", "name": "Fall",
@ -64,11 +69,6 @@ animations = [ {
"loop": true, "loop": true,
"name": "Jump", "name": "Jump",
"speed": 5.0 "speed": 5.0
}, {
"frames": [ ExtResource( 9 ), ExtResource( 27 ), ExtResource( 26 ), ExtResource( 12 ), ExtResource( 35 ), ExtResource( 34 ), ExtResource( 36 ), ExtResource( 10 ), ExtResource( 30 ), ExtResource( 28 ), ExtResource( 21 ), ExtResource( 32 ), ExtResource( 8 ), ExtResource( 18 ) ],
"loop": true,
"name": "Warp",
"speed": 20.0
} ] } ]
[sub_resource type="RectangleShape2D" id=2] [sub_resource type="RectangleShape2D" id=2]
@ -76,9 +76,6 @@ extents = Vector2( 5.0126, 5.32944 )
[node name="Player" type="KinematicBody2D"] [node name="Player" type="KinematicBody2D"]
script = ExtResource( 25 ) script = ExtResource( 25 )
__meta__ = {
"_edit_group_": true
}
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="."]
margin_left = -25.041 margin_left = -25.041

View file

@ -1,54 +0,0 @@
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():
#var myip = IP.get_local_addresses()
#var interfaces = IP.get_local_interfaces ()
#$HostPanel/label_myip.text = "IP "+myip[0]+". "+interfaces[0]
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_singleplayer_button_up():
var _letsgo = get_tree().change_scene("res://world_scenes/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

@ -3,7 +3,7 @@
[ext_resource path="res://misc/fonts/font_buttons.tres" type="DynamicFont" id=1] [ext_resource path="res://misc/fonts/font_buttons.tres" type="DynamicFont" id=1]
[ext_resource path="res://misc/fonts/field_labels.tres" type="DynamicFont" id=2] [ext_resource path="res://misc/fonts/field_labels.tres" type="DynamicFont" id=2]
[ext_resource path="res://misc/fonts/fieldfonts.tres" type="DynamicFont" id=3] [ext_resource path="res://misc/fonts/fieldfonts.tres" type="DynamicFont" id=3]
[ext_resource path="res://scenes/menu.gd" type="Script" id=4] [ext_resource path="res://scripts/menu.gd" type="Script" id=4]
[ext_resource path="res://Sounds/mus_test.ogg" type="AudioStream" id=5] [ext_resource path="res://Sounds/mus_test.ogg" type="AudioStream" id=5]
[ext_resource path="res://Backgrounds/bkMountains.png" type="Texture" id=6] [ext_resource path="res://Backgrounds/bkMountains.png" type="Texture" id=6]
[ext_resource path="res://misc/panel_mainmenu.tres" type="StyleBox" id=7] [ext_resource path="res://misc/panel_mainmenu.tres" type="StyleBox" id=7]
@ -27,6 +27,12 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Camera2D" type="Camera2D" parent="."]
anchor_mode = 0
current = true
smoothing_enabled = true
smoothing_speed = 10.0
[node name="Header2" type="Label" parent="."] [node name="Header2" type="Label" parent="."]
margin_right = 158.0 margin_right = 158.0
margin_bottom = 11.0 margin_bottom = 11.0
@ -158,7 +164,90 @@ margin_bottom = -62.0
hint_tooltip = "Start a singleplayer game" hint_tooltip = "Start a singleplayer game"
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
custom_fonts/font = ExtResource( 1 ) custom_fonts/font = ExtResource( 1 )
text = "Force Start" text = "Single player"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Game Lobby" type="Panel" parent="."]
anchor_left = 0.0125
anchor_top = 0.0888889
anchor_right = 0.0125
anchor_bottom = 0.0888889
margin_left = 648.0
margin_top = 17.0
margin_right = 1256.0
margin_bottom = 318.0
custom_styles/panel = ExtResource( 7 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Header4" type="Label" parent="Game Lobby"]
margin_left = -7.38599
margin_top = -48.0
margin_right = 150.614
margin_bottom = -37.0
rect_scale = Vector2( 4, 4 )
custom_fonts/font = ExtResource( 2 )
text = "pregame lobby"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="PlayersPanel" type="Panel" parent="Game Lobby"]
anchor_left = 0.0125
anchor_top = 0.0888889
anchor_right = 0.0125
anchor_bottom = 0.0888889
margin_left = 352.4
margin_top = 4.24444
margin_right = 584.4
margin_bottom = 228.244
custom_styles/panel = ExtResource( 7 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Game Lobby/PlayersPanel"]
anchor_right = 1.0
margin_top = 8.0
margin_bottom = 19.0
custom_fonts/font = ExtResource( 2 )
text = "connected Players"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Game Lobby"]
anchor_right = 1.0
margin_top = 7.0
margin_bottom = 18.0
custom_fonts/font = ExtResource( 2 )
text = "General"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Btn_Disconnect" type="Button" parent="Game Lobby"]
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -288.0
margin_top = -38.0
margin_right = -206.0
margin_bottom = -17.0
hint_tooltip = "Join an online game with above parameters"
mouse_default_cursor_shape = 2
custom_fonts/font = ExtResource( 1 )
text = "Disconnect"
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -262,21 +351,6 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="CheckBox" type="CheckBox" parent="HostPanel"]
margin_left = 88.0
margin_top = 104.0
margin_right = 264.0
margin_bottom = 128.0
hint_tooltip = "Tonytins mode! Duh!"
custom_fonts/font = ExtResource( 3 )
disabled = true
toggle_mode = false
shortcut_in_tooltip = false
text = "Tonytins Mode"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HostGameBtn" type="Button" parent="HostPanel"] [node name="HostGameBtn" type="Button" parent="HostPanel"]
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 1.0 anchor_top = 1.0

File diff suppressed because one or more lines are too long

69
scripts/menu.gd Normal file
View file

@ -0,0 +1,69 @@
extends Control
var host_port = 2675
var maxplayers
var ip = "127.0.0.1"
var port = 2670
var players = {}
var playername
func _ready():
get_tree().connect("connected_to_server", self, "_connected_ok")
get_tree().connect("connection_failed", self, "_connected_fail")
get_tree().connect("server_disconnected", self, "_server_disconnect")
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.text
port = $JoinPanel/join_port.value
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):
playername = $GeneralPanel/player_name.text
maxplayers = $HostPanel/playercount.value
var host = NetworkedMultiplayerENet.new()
var hostresult = host.create_server(port, maxplayers) # ports, maxplayers
if (hostresult==OK):
print("Netplay - No conflicts. Starting Server")
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."
$Camera2D.position.x += 640
else:
print("Netplay - Cant start server")
#Goto a lobby instance
func join_game():
playername = $GeneralPanel/player_name.text
var host = NetworkedMultiplayerENet.new()
var joinresult = host.create_client(ip, port)
if (joinresult==OK):
get_tree().set_network_peer(host)
print("Netplay - It worked! I should be connecting...")
else:
print("Netplay - I was unable to connect to the server.")
func _connected_ok():
print("Netplay - Built-in Signal - It worked! Im connected!")
func _connected_fail():
print("Netplay - Built-in Signal - It failed")

View file

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