Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
Help with Tic-Tac-Toe
Old
kaufill
Member
 
Status: Offline
Posts: 18
Join Date: Dec 2015
Thumbs down Help with Tic-Tac-Toe - 01-08-2016, 11:20 AM

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!
Attached Files
File Type: a2w GameTakeTwo.a2w (286.1 KB, 1 views)
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 01-18-2016, 10:29 PM

Quote:
Originally Posted by kaufill View Post
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
Attached Files
File Type: a2w T3Demo.a2w (432.9 KB, 1 views)


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.