cleanup
This commit is contained in:
parent
b74b472573
commit
8040d708e7
4 changed files with 0 additions and 22 deletions
|
|
@ -154,7 +154,6 @@ func _on_request_timeout():
|
||||||
# Clean up timer
|
# Clean up timer
|
||||||
request_timer.queue_free()
|
request_timer.queue_free()
|
||||||
request_timer = null
|
request_timer = null
|
||||||
# Call your secondary processing function here
|
|
||||||
write_log("HTTP Request failed, starting server process")
|
write_log("HTTP Request failed, starting server process")
|
||||||
write_log(server_path + "/index.js")
|
write_log(server_path + "/index.js")
|
||||||
server_process_id = OS.create_process("node", [server_path + "/index.js"])
|
server_process_id = OS.create_process("node", [server_path + "/index.js"])
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,37 @@
|
||||||
class_name Game extends Node
|
class_name Game extends Node
|
||||||
|
|
||||||
# This script can be attached to your main Game node that contains both
|
|
||||||
# the menu and the chess game components
|
|
||||||
|
|
||||||
@onready var menuContainer = $MenuContainer
|
@onready var menuContainer = $MenuContainer
|
||||||
@onready var chessGame = $ChessGame
|
@onready var chessGame = $ChessGame
|
||||||
@onready var stateMachine = $StateMachine
|
@onready var stateMachine = $StateMachine
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# Show menu on startup
|
|
||||||
if menuContainer:
|
if menuContainer:
|
||||||
menuContainer.visible = true
|
menuContainer.visible = true
|
||||||
|
|
||||||
# Hide chess game initially
|
|
||||||
if chessGame:
|
if chessGame:
|
||||||
chessGame.visible = false
|
chessGame.visible = false
|
||||||
|
|
||||||
# Connect menu signals
|
|
||||||
if menuContainer and menuContainer.has_signal("new_game_requested"):
|
if menuContainer and menuContainer.has_signal("new_game_requested"):
|
||||||
menuContainer.connect("new_game_requested", Callable(self, "_on_new_game_started"))
|
menuContainer.connect("new_game_requested", Callable(self, "_on_new_game_started"))
|
||||||
|
|
||||||
func _on_new_game_started():
|
func _on_new_game_started():
|
||||||
print("Starting new game...")
|
print("Starting new game...")
|
||||||
|
|
||||||
# Show chess game
|
|
||||||
if chessGame:
|
if chessGame:
|
||||||
chessGame.visible = true
|
chessGame.visible = true
|
||||||
|
|
||||||
# You can add additional game initialization logic here if needed
|
|
||||||
# For example, configuring game options based on menu selections
|
|
||||||
|
|
||||||
# Ensure the chess game is properly initialized
|
|
||||||
if !chessGame.is_inside_tree():
|
if !chessGame.is_inside_tree():
|
||||||
await chessGame.ready
|
await chessGame.ready
|
||||||
|
|
||||||
# Start game logic
|
|
||||||
_start_game_logic()
|
_start_game_logic()
|
||||||
|
|
||||||
func _start_game_logic():
|
func _start_game_logic():
|
||||||
# If StateMachine is already initialized in the Chess game, this may not be needed
|
|
||||||
if stateMachine and stateMachine.has_method("transitionToNextState"):
|
if stateMachine and stateMachine.has_method("transitionToNextState"):
|
||||||
stateMachine.transitionToNextState(Constants.WHITE_TURN)
|
stateMachine.transitionToNextState(Constants.WHITE_TURN)
|
||||||
|
|
||||||
# Add any additional game start logic here
|
|
||||||
|
|
||||||
# If you need to open a specific scene or create nodes dynamically:
|
|
||||||
# var chess_scene = load("res://Scenes/ChessGame.tscn").instantiate()
|
|
||||||
# add_child(chess_scene)
|
|
||||||
|
|
||||||
# Handle escape key to show menu during game
|
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
if event is InputEventKey:
|
if event is InputEventKey:
|
||||||
if event.pressed and event.keycode == KEY_ESCAPE:
|
if event.pressed and event.keycode == KEY_ESCAPE:
|
||||||
|
|
@ -58,7 +41,5 @@ func _toggle_menu():
|
||||||
if menuContainer:
|
if menuContainer:
|
||||||
menuContainer.visible = !menuContainer.visible
|
menuContainer.visible = !menuContainer.visible
|
||||||
|
|
||||||
# Optional: Pause game when menu is visible
|
|
||||||
if menuContainer.visible and chessGame:
|
if menuContainer.visible and chessGame:
|
||||||
# You might want to pause the game or disable input
|
|
||||||
pass
|
pass
|
||||||
|
|
@ -103,7 +103,6 @@ func distance_to_line_segment(point: Vector2, line_start: Vector2, line_end: Vec
|
||||||
# Return distance from point to projection
|
# Return distance from point to projection
|
||||||
return (point - projection).length()
|
return (point - projection).length()
|
||||||
|
|
||||||
# Call this when the map changes to update dot highlights
|
|
||||||
func update_dots():
|
func update_dots():
|
||||||
if highlight_dots and map_screen != null:
|
if highlight_dots and map_screen != null:
|
||||||
generate_dots()
|
generate_dots()
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ static func convert_algebraic_to_location(square: String) -> String:
|
||||||
file_num = file_num
|
file_num = file_num
|
||||||
var rank_num = 8 - rank
|
var rank_num = 8 - rank
|
||||||
|
|
||||||
# Return location in your game's format
|
|
||||||
return "%d-%d" % [file_num, rank_num]
|
return "%d-%d" % [file_num, rank_num]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue