This is the third and final version of TicTacToe.
Demo:
Tic Tac Toe
Source:
Source.zip
Its the final version because TicTacToe is getting boring, and I've learnt some of the
key lessons to be learnt as a beginner in the Silverlight space. I'll do other Silverlight
projects but for now, TicTacToe is finished.
There's been some fixes as follows since the last version:
- Added a much harder computer player. In fact I thought it unbeatable until just now I discovered the flaw.
- Removed the line that indicates a win; it was tacky
- Added animations! This really needed some timelines. Discussed more below.
- General tidy up of UI
- Fixed the mouse over of the buttons so that mouse overing the text works as well
I thought it a good time to introduce some animations. So I thought I'd ditch the tacky winner's line,
and instead make the items in the winning row do some sort of animation. I acheived this by
making the naughts and crosses objects implement IAnimatable, indicating they would have a
method called PlayWinningAnimation(). I created my timeline in Blend and then called the timeline
from withing this method. The result is that when the game is over and someone wins,
the game detects which row won, and then tells each item in that row to PlayWinningAnimation().
In early stages when it was faulty, both the Naughts and the Crosses would animate at the same time!
The computer is much harder now. So hard that until I just uploaded the demo and source, I didn't
think the human player could win. The down side is that if the human DOES win, the winning
animations don't actually play. However there IS a way to beat the computer. Can you find it?
If so, let me know on my
blog.
Fixing the last issue on the list above was quite easy. In Blend, I was able to group the text and
the rectangle as 1 canvas. I then applied my mouse over events to the canvas rather than the
rectangle.
Some things I didn't get to complete include:
- Ability to select computer difficulty.
- Create button down states/visuals
- Stream line play; it's kind of clunky having to click "new game" and then select who goes first
- Pretend that the computer was thinking with delay; thread.sleep just caused UI problems