Start work on menus and add music (?)
This commit is contained in:
parent
9c3468e94d
commit
f06526825d
16 changed files with 145 additions and 59 deletions
8
Graphics/Menu.tscn
Normal file
8
Graphics/Menu.tscn
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[gd_scene format=2]
|
||||||
|
|
||||||
|
[node name="Control" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ onready var world = $world
|
||||||
onready var systems = $systems
|
onready var systems = $systems
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
randomize()
|
|
||||||
ui.connect("command", world, "process_command")
|
ui.connect("command", world, "process_command")
|
||||||
|
|
||||||
func process_command(cmd: UICommand):
|
func process_command(cmd: UICommand):
|
||||||
|
|
|
@ -12,6 +12,8 @@ scale = Vector2( 2, 2 )
|
||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
mapToLoad = 1
|
mapToLoad = 1
|
||||||
|
|
||||||
|
[node name="players" type="Node2D" parent="world"]
|
||||||
|
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="ui" parent="CanvasLayer" instance=ExtResource( 3 )]
|
[node name="ui" parent="CanvasLayer" instance=ExtResource( 3 )]
|
||||||
|
|
70
Scenes/Global/Multiplayer.gd
Normal file
70
Scenes/Global/Multiplayer.gd
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
const SERVER_PORT = 5513
|
||||||
|
const MAX_PLAYERS = 30
|
||||||
|
|
||||||
|
export var player_name = ""
|
||||||
|
var player_info = {}
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
player_name = "tider-" + str(randi() % 1000)
|
||||||
|
get_tree().connect("network_peer_connected", self, "_player_connected")
|
||||||
|
get_tree().connect("network_peer_disconnected", self, "_player_disconnected")
|
||||||
|
get_tree().connect("connected_to_server", self, "_connected_ok")
|
||||||
|
get_tree().connect("connection_failed", self, "_connected_fail")
|
||||||
|
get_tree().connect("server_disconnected", self, "_server_disconnected")
|
||||||
|
|
||||||
|
func host():
|
||||||
|
var peer = NetworkedMultiplayerENet.new()
|
||||||
|
peer.create_server(SERVER_PORT, MAX_PLAYERS)
|
||||||
|
get_tree().set_network_peer(peer)
|
||||||
|
print("Hosting")
|
||||||
|
player_info[1] = { name=player_name }
|
||||||
|
#mapLoader.map.spawn_player(peer.get_unique_id())
|
||||||
|
|
||||||
|
func join(addr: String):
|
||||||
|
var peer = NetworkedMultiplayerENet.new()
|
||||||
|
peer.create_client(addr, SERVER_PORT)
|
||||||
|
get_tree().network_peer = peer
|
||||||
|
print("Connecting to", addr)
|
||||||
|
|
||||||
|
func leave():
|
||||||
|
var peer = get_tree().network_peer
|
||||||
|
if get_tree().is_network_server():
|
||||||
|
#TODO Do something if server
|
||||||
|
pass
|
||||||
|
elif peer != null:
|
||||||
|
#TODO Send leave message
|
||||||
|
pass
|
||||||
|
get_tree().network_peer = null
|
||||||
|
|
||||||
|
func _player_connected(id):
|
||||||
|
rpc_id(id, "register_player", player_name)
|
||||||
|
if get_tree().is_network_server():
|
||||||
|
pass
|
||||||
|
#rpc_id(id, "spawn_players", mapLoader.map.all_players())
|
||||||
|
|
||||||
|
func _player_disconnected(id):
|
||||||
|
print(player_info[id].name, " (", id, ") disconnected")
|
||||||
|
player_info.erase(id)
|
||||||
|
|
||||||
|
func _connected_ok():
|
||||||
|
print("Connected to server")
|
||||||
|
|
||||||
|
func _server_disconnected():
|
||||||
|
print("Disconnected from server")
|
||||||
|
|
||||||
|
func _connected_fail():
|
||||||
|
print("Connection failed")
|
||||||
|
|
||||||
|
remote func register_player(username: String):
|
||||||
|
var id = get_tree().get_rpc_sender_id()
|
||||||
|
player_info[id] = { name=username }
|
||||||
|
print(player_info[id].name, " (", id, ") connected")
|
||||||
|
|
||||||
|
remote func spawn_players(players):
|
||||||
|
for player_id in players:
|
||||||
|
pass
|
||||||
|
#mapLoader.map.spawn_player(player_id)
|
||||||
|
# Spawn myself as well
|
||||||
|
#mapLoader.map.rpc("spawn_player", get_tree().network_peer.get_unique_id())
|
14
Scenes/Global/Music.tscn
Normal file
14
Scenes/Global/Music.tscn
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Sounds/BGM/Bluemillenium_-_Je_suis_un_Phoenix_1.ogg" type="AudioStream" id=1]
|
||||||
|
|
||||||
|
[node name="Music" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="BGM" type="AudioStreamPlayer" parent="."]
|
||||||
|
stream = ExtResource( 1 )
|
||||||
|
bus = "BGM"
|
4
Scenes/Menu.gd
Normal file
4
Scenes/Menu.gd
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
$"/root/Music/BGM".play()
|
11
Scenes/Menu.tscn
Normal file
11
Scenes/Menu.tscn
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Menu.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Control" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
|
@ -1,41 +0,0 @@
|
||||||
[gd_scene load_steps=8 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://Scenes/Maps/odyssey.tscn" type="PackedScene" id=1]
|
|
||||||
[ext_resource path="res://Actors/Player/Player.tscn" type="PackedScene" id=2]
|
|
||||||
[ext_resource path="res://Scenes/UI.tscn" type="PackedScene" id=3]
|
|
||||||
[ext_resource path="res://Scenes/World.gd" type="Script" id=4]
|
|
||||||
[ext_resource path="res://Scenes/Game.gd" type="Script" id=5]
|
|
||||||
[ext_resource path="res://Scenes/UI.gd" type="Script" id=6]
|
|
||||||
[ext_resource path="res://Scenes/Maps/runtime.tscn" type="PackedScene" id=7]
|
|
||||||
|
|
||||||
|
|
||||||
[node name="scene" type="Node"]
|
|
||||||
script = ExtResource( 5 )
|
|
||||||
|
|
||||||
[node name="world" type="Node2D" parent="."]
|
|
||||||
scale = Vector2( 2, 2 )
|
|
||||||
script = ExtResource( 4 )
|
|
||||||
player_path = NodePath("player")
|
|
||||||
map_path = NodePath("odyssey")
|
|
||||||
|
|
||||||
[node name="runtime" parent="world" instance=ExtResource( 7 )]
|
|
||||||
visible = false
|
|
||||||
|
|
||||||
[node name="odyssey" parent="world" instance=ExtResource( 1 )]
|
|
||||||
|
|
||||||
[node name="player" parent="world" instance=ExtResource( 2 )]
|
|
||||||
position = Vector2( 206.017, 250.966 )
|
|
||||||
z_index = 1
|
|
||||||
is_controlled = true
|
|
||||||
|
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
|
||||||
|
|
||||||
[node name="ui" parent="CanvasLayer" instance=ExtResource( 3 )]
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
margin_right = 0.0
|
|
||||||
margin_bottom = 0.0
|
|
||||||
mouse_filter = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 3
|
|
||||||
script = ExtResource( 6 )
|
|
12
Scenes/UI.gd
12
Scenes/UI.gd
|
@ -3,24 +3,16 @@ extends Control
|
||||||
signal command(command)
|
signal command(command)
|
||||||
|
|
||||||
enum ServerMenuItem {
|
enum ServerMenuItem {
|
||||||
HOST_SERVER,
|
|
||||||
JOIN_SERVER,
|
|
||||||
SERVER_INFO
|
SERVER_INFO
|
||||||
}
|
}
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
# Add options to menu buttons
|
# Add options to menu buttons
|
||||||
var serverMenu = $Menu/Margins/Grid/Server.get_popup()
|
var serverMenu = $Menu/Margins/Grid/Server.get_popup()
|
||||||
serverMenu.add_item("Start hosting", ServerMenuItem.HOST_SERVER)
|
|
||||||
serverMenu.add_item("Join instance", ServerMenuItem.JOIN_SERVER)
|
|
||||||
serverMenu.connect("id_pressed", self, "_server_option_chosen")
|
serverMenu.connect("id_pressed", self, "_server_option_chosen")
|
||||||
|
serverMenu.add_item("Server info", ServerMenuItem.SERVER_INFO)
|
||||||
|
|
||||||
func _server_option_chosen(id) -> void:
|
func _server_option_chosen(id) -> void:
|
||||||
match id:
|
match id:
|
||||||
ServerMenuItem.HOST_SERVER:
|
ServerMenuItem.SERVER_INFO:
|
||||||
# TODO HOST
|
|
||||||
$ServerInfoPopup.popup_centered()
|
$ServerInfoPopup.popup_centered()
|
||||||
pass
|
|
||||||
ServerMenuItem.JOIN_SERVER:
|
|
||||||
# TODO JOIN
|
|
||||||
pass
|
|
||||||
|
|
|
@ -59,12 +59,8 @@ size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="Grid" type="GridContainer" parent="Menu/Margins"]
|
[node name="Grid" type="GridContainer" parent="Menu/Margins"]
|
||||||
anchor_right = 1.0
|
margin_right = 144.0
|
||||||
anchor_bottom = 1.0
|
margin_bottom = 20.0
|
||||||
margin_left = 4.0
|
|
||||||
margin_top = 4.0
|
|
||||||
margin_right = 4.0
|
|
||||||
margin_bottom = 4.0
|
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
custom_constants/vseparation = 4
|
custom_constants/vseparation = 4
|
||||||
|
|
|
@ -22,6 +22,9 @@ margin_right = 376.0
|
||||||
margin_bottom = 336.0
|
margin_bottom = 336.0
|
||||||
custom_styles/panel = SubResource( 1 )
|
custom_styles/panel = SubResource( 1 )
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="DragHandle" type="Panel" parent="."]
|
[node name="DragHandle" type="Panel" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
|
@ -27,7 +27,7 @@ func _ready():
|
||||||
player.transform.origin = (spawnpoints[0] as Node2D).transform.origin
|
player.transform.origin = (spawnpoints[0] as Node2D).transform.origin
|
||||||
else:
|
else:
|
||||||
print("Map does not have Player spawnpoint POI! Spawning at origin (very bad)")
|
print("Map does not have Player spawnpoint POI! Spawning at origin (very bad)")
|
||||||
add_child(player)
|
$players.add_child(player)
|
||||||
for tilemap in map.tilemaps:
|
for tilemap in map.tilemaps:
|
||||||
if tilemap is MapTiles:
|
if tilemap is MapTiles:
|
||||||
tilemap.set_occluder_origin(player)
|
tilemap.set_occluder_origin(player)
|
||||||
|
|
BIN
Sounds/BGM/Bluemillenium_-_Je_suis_un_Phoenix_1.ogg
Normal file
BIN
Sounds/BGM/Bluemillenium_-_Je_suis_un_Phoenix_1.ogg
Normal file
Binary file not shown.
15
Sounds/BGM/Bluemillenium_-_Je_suis_un_Phoenix_1.ogg.import
Normal file
15
Sounds/BGM/Bluemillenium_-_Je_suis_un_Phoenix_1.ogg.import
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="ogg_vorbis"
|
||||||
|
type="AudioStreamOGGVorbis"
|
||||||
|
path="res://.import/Bluemillenium_-_Je_suis_un_Phoenix_1.ogg-c4c618afdcccb82197d6f44edbf07e3d.oggstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sounds/BGM/Bluemillenium_-_Je_suis_un_Phoenix_1.ogg"
|
||||||
|
dest_files=[ "res://.import/Bluemillenium_-_Je_suis_un_Phoenix_1.ogg-c4c618afdcccb82197d6f44edbf07e3d.oggstr" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=true
|
||||||
|
loop_offset=0
|
9
default_bus_layout.tres
Normal file
9
default_bus_layout.tres
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_resource type="AudioBusLayout" format=2]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
bus/1/name = "BGM"
|
||||||
|
bus/1/solo = false
|
||||||
|
bus/1/mute = false
|
||||||
|
bus/1/bypass_fx = false
|
||||||
|
bus/1/volume_db = -4.00569
|
||||||
|
bus/1/send = "Master"
|
|
@ -132,6 +132,10 @@ config/name="odyssey"
|
||||||
run/main_scene="res://Scenes/Game.tscn"
|
run/main_scene="res://Scenes/Game.tscn"
|
||||||
config/icon="res://icon.png"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
Music="*res://Scenes/Global/Music.tscn"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/width=1280
|
window/size/width=1280
|
||||||
|
|
Reference in a new issue