Forum Discussion

AaronBurgessAU's avatar
AaronBurgessAU
Community Member
23 days ago

Tic Tac Toe using Storyline triggers

 

I just saw SAHILSANDUJA​ share a wonderful example of Tic Tac Toe using Javascript. And I thought to myself, I wonder if I can do this using only triggers. Also I can't code in Javascript.

The game's base layer has the board and clickable objects. When a player clicks on any empty space it assigns the correct shape based on a toggling true/false variable.

At the moment the first shape X or O is randomised. I could have let the user select what they wanted, but for this it didn't matter.

The base layer shows 2 layers. One is checking to see if the naughts win, and the other layer checking to see if the crosses win. This is done using 8 different checks for both layers, in winnable combinations eg:

If Row1Column1 = X
and Row1Column2 = X
and Row1Column3 = X

then show layer X WIN

or 

If Row1Column1 = X
and Row2Column2 = X
and Row3Colum3 = X

then show layer X WIN

This layer reveals a green line that matched the winning combination. Again this is done by testing 8 times until the correct match is made. Afterwards I realised I should have assigned a number to each combination and then what ever number the variable is the assigned green line is shown.

Play the game here

1 Reply

  • AaronBurgessAU​ I can't believe how late to the (literal) game I am here, but this is such a cool idea that you took SAHILSANDUJA​'s share and upped the anti with this "two triggers only" constraint. Such a creative way to push your skills. Sophisticated and elegant logic. Love it. 

    I went ahead and grabbed a screenshot of the game you made and added it to your post—I feel like sometimes when there's a cover image you end up getting more interaction, which this example definitely deserves! Excited to see what you make next :)