Welcome all. Construct2 the best!
I cannot imagine how there could be a noughts and crosses to make a game the construct2 with a program.
Help to understand his logic for me.
Develop games in your browser. Powerful, performant & highly capable.
LordViperion nothing in life is EASY as pie blackhornet gave you link learn from it. blackhornet cannot teach you or write a game for you. blackhornet only can guide you
You could also do something tricky like this:
https://dl.dropboxusercontent.com/u/542 ... ctoe2.capx
But really tic tac toe is rathar simple although tedious. I like to opt for as few object types as possible but you could just as well just make a sprite per location.
Each sprite will have 3 animation frames "blank", "x" and "o". Be sure to set the animation speed to 0 so the frames don't change.
Placing an x or o is just a matter of using the event:
on sprite clicked
--- set animation frame to 1 or 2
I used a variable to keep track of whose turn it is, and switched it every time a player placed a piece.
global number turn=1
--- set animation frame to turn
--- set turn to 3-turn
Setting turn to 3-turn is just a simple way to toggle turn between the values 2 and 1.
Next comes the tedious part of checking for a win. It's very simple in concept, just look at each row,column and diagonal and see if there's three x's or o's in any of them. This is where you choose an approach you like.
One way is to use an array that you set from the visible x' and o's. This then makes it simpler to write like other programming languages, so you can check certain locations.
Here's an incomplete example of a very verbose way of checking for each win, for each player.
https://dl.dropboxusercontent.com/u/542 ... ctoe3.capx
Using loops help a lot to simplify things, and blackhornet's tutorial does just that.
Another way as I have done is to utilize picking to pick a row, column or diagonal in some way like I did.