feat: Add a loading screen, a lobby scene, and a new main game script, along with a custom font.

This commit is contained in:
Yogi Wiguna
2026-03-17 11:11:00 +08:00
parent 49c8d794c2
commit b877f94e34
8 changed files with 345 additions and 17 deletions
+39 -13
View File
@@ -364,11 +364,19 @@ func _start_pre_game_countdown():
@rpc("call_local", "reliable")
func sync_countdown(text: String):
var label = get_node_or_null("CountdownLabel")
# Use a CanvasLayer to ensure the countdown is on top of everything
var countdown_layer = get_node_or_null("CountdownLayerUI")
if not countdown_layer:
countdown_layer = CanvasLayer.new()
countdown_layer.name = "CountdownLayerUI"
countdown_layer.layer = 100 # Very high priority
add_child(countdown_layer)
var label = countdown_layer.get_node_or_null("CountdownLabel")
if not label and text != "":
label = Label.new()
label.name = "CountdownLabel"
add_child(label)
countdown_layer.add_child(label)
# Center and Style
label.anchors_preset = Control.PRESET_CENTER
@@ -378,15 +386,20 @@ func sync_countdown(text: String):
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
label.add_theme_font_size_override("font_size", 120)
label.add_theme_font_size_override("font_size", 140)
label.add_theme_color_override("font_outline_color", Color.BLACK)
label.add_theme_constant_override("outline_size", 12)
label.add_theme_constant_override("outline_size", 20)
label.add_theme_color_override("font_color", Color.YELLOW)
# Use Nougat font if available
var nougat = load("res://assets/fonts/Nougat-ExtraBlack.ttf")
if nougat:
label.add_theme_font_override("font", nougat)
if label:
label.text = text
if text == "":
label.queue_free()
countdown_layer.queue_free()
elif text == "GO!":
label.add_theme_color_override("font_color", Color.GREEN)
@@ -687,8 +700,8 @@ func _start_game():
wait_time += 0.2
# Allow socket/peer to stabilize before blasting RPCs
# Snappier delay for LAN mode
var delay = 0.5 if LobbyManager.is_lan_mode else 2.0
# Snappier delay since we already waited for scene load
var delay = 0.2 if LobbyManager.is_lan_mode else 0.5
await get_tree().create_timer(delay).timeout
# NOW assign spawn positions for EVERYONE (Host, Client, Bots)
@@ -2391,8 +2404,16 @@ func _on_quit_match_pressed():
get_tree().paused = false # Ensure unpaused when returning to menu
# Properly disconnect from Nakama and clear lobby state to prevent desync
LobbyManager.leave_room()
# Return to lobby or main menu
get_tree().change_scene_to_file("res://scenes/lobby.tscn")
# Return to lobby via loading screen
var loading_screen_scene = load("res://scenes/loading_screen/loading_screen.tscn")
if loading_screen_scene:
var loading_screen = loading_screen_scene.instantiate()
get_tree().root.add_child(loading_screen)
loading_screen.load_level("res://scenes/lobby.tscn")
else:
# Fallback
get_tree().change_scene_to_file("res://scenes/lobby.tscn")
func _on_settings_back_pressed():
var pause_menu = get_node_or_null("PauseMenu")
@@ -2418,11 +2439,16 @@ func _on_joystick_toggled(enabled: bool):
touch_controls._save_settings()
func can_rpc() -> bool:
if not multiplayer.has_multiplayer_peer() or multiplayer.multiplayer_peer.get_connection_status() != MultiplayerPeer.CONNECTION_CONNECTED:
return false
if not multiplayer.has_multiplayer_peer(): return false
if multiplayer.multiplayer_peer.get_connection_status() != MultiplayerPeer.CONNECTION_CONNECTED: return false
if LobbyManager.is_lan_mode:
return true
var nakama = get_node_or_null("/root/NakamaManager")
if nakama and nakama.has_method("is_connected_to_nakama") and not nakama.is_connected_to_nakama():
return false
if nakama and nakama.has_method("is_connected_to_nakama"):
return nakama.is_connected_to_nakama()
return true
@rpc("authority", "call_local", "reliable")