Godot Version
Godot 4.3`
Question
Also here is a description of my game: So i’ve been coding like a app game that you can play The Ultimate Tic Tac Toe Or Simple Tic Tac Toe with AI and Multiplayer, or by yourself Here is what ultimate tic tac toe looks like:
and here is simple:
Well now that the buttons have been seperated, how do I make the buttons bigger? Like a tiny bit, I can barely click it…
here is a video
Here is ultimatetictactoe.gd: extends Node
Array to hold references to mini boards
var mini_boards =
func _ready():
var grid_container = get_node(“GridContainer”) # Ensure the GridContainer node is present
if not grid_container:
print(“GridContainer not found!”)
return # Exit if the GridContainer is not found
print("Creating mini boards...")
for i in range(3):
for j in range(3):
var mini_board = preload("res://miniboard.tscn").instantiate() # Use instantiate() instead of instance()
if mini_board is Control: # Check if mini_board is of type Control
mini_board.set_custom_minimum_size(Vector2(200, 200)) # Set minimum size for the mini board
# Set button sizes for each cell's button
var cell_button_path = "Cell_" + str(i * 3 + j) + "/Button" # Replace "Button" with the actual button's name
var button = mini_board.get_node(cell_button_path) # Get the button node
if button and button is Button:
button.set_custom_minimum_size(Vector2(450, 350)) # Adjust button size here
button.rect_size = Vector2(450, 350) # Ensure the button size is set directly
else:
print("Button not found at path: ", cell_button_path) # Print if button is not found
mini_boards.append(mini_board)
grid_container.add_child(mini_board) # Add mini boards to the grid
print("Mini board added at position: ", i, j)
print("All mini boards created successfully.")
here is miniboard.gd: extends Control
var current_player = “X” # Keep track of the current player
var cells = # Store references to buttons
func _ready():
# Store cell buttons in the array
for i in range(3):
for j in range(3):
var cell = $GridContainer.get_child(i * 3 + j)
cells.append(cell)
# Connect the pressed signal using Callable
cell.connect(“pressed”, Callable(self, “_on_Cell_pressed”).bind(i * 3 + j))
func _on_Cell_pressed(cell_index: int):
var cell = cells[cell_index] # Get the cell from the index
if cell.text == “”:
cell.text = current_player # Set the cell text to current player
if check_winner(): # Check for a winner
print(current_player + " wins!") # Notify winner
current_player = “O” if current_player == “X” else “X” # Switch player
func check_winner() → bool:
# Logic to check for a winner
for i in range(3):
# Check rows
if cells[i * 3].text == current_player and cells[i * 3 + 1].text == current_player and cells[i * 3 + 2].text == current_player:
return true # Row win
# Check columns
if cells[i].text == current_player and cells[i + 3].text == current_player and cells[i + 6].text == current_player:
return true # Column win
# Check diagonals
if cells[0].text == current_player and cells[4].text == current_player and cells[8].text == current_player:
return true # Diagonal win (top-left to bottom-right)
if cells[2].text == current_player and cells[4].text == current_player and cells[6].text == current_player:
return true # Diagonal win (top-right to bottom-left)
return false # No winner yet
and here is playmodeselectionultimate.gd: extends Control
Called when the scene is loaded
func _ready():
# Check and connect MultiplayerButton
var multiplayer_button = $MultiplayerButton # Change this if it is nested
if multiplayer_button:
multiplayer_button.connect(“pressed”, Callable(self, “_on_MultiplayerButton_pressed”))
else:
print(“MultiplayerButton not found”)
# Check and connect AIModeButton
var aimode_button = $AIModeButton # Change this if it is nested
if aimode_button:
aimode_button.connect("pressed", Callable(self, "_on_AIModeButton_pressed"))
else:
print("AIModeButton not found")
# Check and connect YourselfButton
var yourself_button = $YourselfButton # Change this if it is nested
if yourself_button:
yourself_button.connect("pressed", Callable(self, "_on_YourselfButton_pressed"))
else:
print("YourselfButton not found")
Functions to handle button presses
func _on_MultiplayerButton_pressed():
print(“MultiplayerButton pressed”)
get_tree().change_scene_to_file(“res://RoomManagement.tscn”) # Navigate to Room Management scene
func _on_AIModeButton_pressed():
print(“AIModeButton pressed”)
get_tree().change_scene_to_file(“res://AIDifficultySelection.tscn”) # Navigate to AI Difficulty Selection scene
func _on_YourselfButton_pressed():
var tree = get_tree()
if tree == null:
print(“Tree is null! Exiting function.”)
return
print(“YourselfButton pressed”)
tree.change_scene_to_file(“res://ultimate_tic_tac_toe.tscn”) # Navigate directly to the game
Add the missing methods to suppress warnings
func _on_multiplayer_pressed() → void:
_on_MultiplayerButton_pressed()
func _on_ai_pressed() → void:
_on_AIModeButton_pressed()
func _on_yourself_pressed() → void:
_on_YourselfButton_pressed()
Here is miniboard.tscn
playmodeselectionultimate.tscn:
ultimate_tic_tac_toe.tscn:
Let me know if you need any other code/pictures/videos to help fix this issue Thank you so much in advance!