OK version 2 is here!
Demo:
Tic Tac Toe
Source:
Source.zip
I took some of the goals I identified after version 1 and implemented them for version 2. While I don't think I'm
doing everything
perfectly yet, I do think this is a lot better than before.
One of the important things I want to achieve while working on this project is to define techniques and design patterns to
support the integration of development and design. Microsoft has provided the tools but as a developer you could still
make it near impossible for the designer to touch the UI elements. For example, Silverlight lets you write inline XAML
and then parse it for output. In my application, one of the things missing was a "line" that showed where the winning
3 pieces were. I could have just wrote some inline xaml for drawing that line, but that means the designer could never
have laid hands on it to make it look better. So in this case that would not have been a good idea. I think it
will be important for the developer to identify how the designer will be able to work with them on a project.
So to that end, I have made sure that
every visual element exists in a separate XAML file. I suppose
I didn't have to separete them; they could all be in the Page.Xaml file. However this technique seems a little
worrying to me. If a designer has all the elements in one file, there's a greater risk of mucking up the
structure that the developer needs for the functional side of the app. Also, I'm not sure how you can duplicate (clone)
a single object if it is mixed in with others in one file; the technique I have used to load multiple naugts/crosses
is to load the cross control from the xaml file. If I used this approach and the cross was in Page.xaml, I'd have
duplicate the
whole game and then find the cross element. Anyway, I'm an Object Oriented kinda guy.
So here's some other improvements I've made:
- Renamed and integrated: there is only 1 project now, and it's called 'TicTacToe'
- Refactoring: Created classes for the logical game board, and for the computer player
- Difficulty: Added additional difficulty levels, but there is no way to select them in game yet so it is hard coded (change the computer player object initialisation in pageload)
- Visual elements are added to the proper containing object. For example, the board is added to the main container, and the crosses and naughts are added to the board, whereas previously it was all to the main container
- The "winners line" as described earlier
What's next?
- The hardest computer setting
- Buttons need work: Currently just rectangles and text - The May futures release might have something to help
- Buttons for selecting computer intelligence
- Enhance the visual elements: looks very simple currently
One other thing I want to implement is a kind of random animation picker. An object could have any number of
timelines specified, and the object class will be responsible for playing those animations randomly.
For example, there might be a cross on the game board. After 10 seconds it "shivers". 20 seconds later it
changes colour. Following the pattern defined above, the desinger could create any number of timelines and
the application will discover the animations.
I've hammerred away at this a lot this week so the next release might not be for a little while now.