extends Node2D # Number of players and current player index var playerAmount = 2 var playerIndex = 0 # Variable to hold the current player's object name var objectName # Kick the game off func _ready(): # Hide character viewer GUI initially $"../characterViewer".hideGet() # Start cycling through players next() # Function to switch to the next player func next(): if playerIndex >= playerAmount: playerIndex = 0 # Construct object name based on player index objectName = "player%d" % playerIndex # Start the current player's activity get_node(objectName).start() playerIndex += 1 # Move to the next player index # Function to display statistics, lots of relative links, may change eventually func stats(): visible = false # Hide game area $"../characterViewer".visible = true get_node(objectName).stop() # Activate back button $"../back".disabled = false $"../back".visible = true # Update player index display in character viewer $"../characterViewer/ScrollContainer/VBoxContainer".get_child(0).text = str(playerIndex - 1) $"../characterViewer/ScrollContainer/VBoxContainer".get_child(0).editable = false # Simulate button press in character viewer (assuming this triggers further actions) $"../characterViewer"._on_button_pressed() # Function to restart the node's state func restart(): visible = true # Show game area $"../characterViewer".visible = false get_node(objectName).start() # Activate back button $"../back".disabled = true $"../back".visible = false # Handler for when the back button is pressed func _on_back_pressed(): restart() # Gives control back to the current player character