I am working on making a Tic-Tac-Toe game, and I can not figure out why an 'X' is painted in the top left spot every time the program is run.
It would probably help if you compiled and ran the program.
I believe the problem lies somewhere in the for loop on lines 53 - 72, but I have looked at it for hours, and can not figure it out.
Andrew Gary wrote:It would probably help if you compiled and ran the program.
Provided that I set up a user named "Andrew" on my hopefully-Windows computer and created some suitable directories for that user and put some suitable images in that directory...
Moving right along then, I looked at your code. I guessed you might be talking about the image which you assigned to a variable named "x" near the beginning. I thought I would search your code to see where that variable was being used, but I got tired of slogging through unrelated instances of the character "x" in the code. I know that "x" seems like a good variable name for an image which is an "X", but trust me, it isn't a good variable name.
So I was reduced to taking your suggestion of looking at the loop where you suspected the problem was located. (You probably suspect rightly.) You're complaining about an X image showing up where you didn't expect one? Then set a breakpoint at line 64 and see what the state of your variables is when your debugger stops there.
Edit: looking farther down from that loop, I see you have some code which does something based on where the user last clicked the mouse. What does it do if the user hasn't ever clicked the mouse?