How to write a function that places pieces on a tictactoe board in a GUI.
Mostra commenti meno recenti
what i have so far for this function is this:
function handles = buttonPress(hObject,handles)
if handles.(hObject.Tag).String == ''
if handles.turnNumber ==1
handles.(hObject.Tag).String = 'o'
else
handles.(hObject.Tag).String = 'x'
end
end
end
I just don't understand what it even does. I am so lost. Please help
3 Commenti
Geoff Hayes
il 25 Apr 2018
rayray - did you write the above code or "borrow" it from someone else? If you wrote it, then how come you don't understand what it does? You must have more than the above code because this function on its own isn't sufficient for your GUI.
This seems like a homework assignment since others have posted similar questions (with near identical code) in this forum, so you may want to start over. Design your GUI first (with the nine controls for the tic-tac-toe board) and then worry about the behaviour when you press each control (i.e. button on the board).
rayray
il 26 Apr 2018
Geoff Hayes
il 26 Apr 2018
Are you calling the buttonPress code from your pushbutton callbacks? (Or whatever controls you are using for the cells in the 3x3 board.)
I think that the above code is missing some logic - how do you know if you should draw an X or O? Why is the turnNumber one? What does this represent?
Risposte (0)
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!