Quote:
Originally Posted by kaufill
I'm attempting to build a tic-tac-toe game.
In order to test small pieces before I build the bigger ones, I am trying to get a 3D text to appear after the user clicks on one box of the board.
When you click the bottom left box (your left), it should turn green and then the text "You WIN!!!" should appear.
Can anyone tell me why this isn't happening?
Thanks for any help!
|
I think you are off to a good start. Both lists and events are the right way to go. One thing to remember is that timing is important. The default for Alice is to use 1 second for each instruction when using lists this can add up to large delays. The answer is to use the delay option (avaiailable my clicking on the “more…” Options available on each instructions) set the delay to 0.
I have attached a variation on the program you submitted. Please note that most of the work is in the setup. I used the vehicle property to “attach the text to its square and the squares to the background square. This is just a convenience so that accidentally moving something during authoring won't cause a lot of work.
Since there are only two players I used a Boolean, world.turn, True = player1 and False = player2. The mouse event passes in the object that was clicked to the takeTurn method. If the object matches one in the chain of if statements it is sent to the corresponding text object, clicking on anything else is thrown away.
The actual work is done in the text objects clickHandler. In the handler the square is checked and if it is open either an X or an O is set in the square and the player is toggled.
The example has two squares so that you can see how it works. That leaves the rest of the game logic for you to implement.
I hope this helps you get on track with your project.
Mark