Skip to content
Andy Brodie edited this page Jan 22, 2018 · 1 revision

Sliding Block Puzzle

This app is a simple game for Windows Phone 7.1 (Mango). It uses a variety of features and techniques of the Windows Phone platform.

I've decided to go with the Publish-Early Publish-Often approach. The single player game is playable, the custom game code isn't finished yet. This documentation will be improved over time. If you see any problems with either the docs or the code, then please start off a discussion and I'll respond as soon as I can.

The application is written in a mixture of Model-View-ViewModel (MVVM) pattern and straight code-behind logic in pages. Getting Started

Once you have the source code downloaded, build the code. On Windows 8, you may get the following error:

The target "GetCopyToOutputDirectoryContentProjectItems" does not exist in the project Locima.SlidingBlock

If you get this, simply download the XNA Game Studio 4.0 Refresh. This happens because XNA Game Studio doesn't install correctly when you install the Windows Phone 7.1 SDK.

If you want to see all the NLog trace that the program emits, then enable the Emulator Console by setting the following registry key: Edition Registry Path Key Type Value 32-bit HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\XDE EnableConsole DWORD 00000001 64-bit HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\XDE

Press F5 and you're good to go! Application Structure

The application is structured with all the pages in the root of the application, then ViewModel and Model namespaces for View Models and Model, respectively, where applicable.

Apart from these namespaces there's the following: Namespace General Purpose Common Some useful commonly used classes Content Created and used by YLAD Controls Windows Phone controls used within the pages Converters Lots of data converters (implementations of IValueConverter] GameTemplates Contains the set up for the single player game (level definitions) Icons The application bar icon files IO Classes and interfaces that abstract all persisted data IO.IsolatedStorage Implementation of all interfaces in the IO namespace using Isolated Storage Messaging Along with ViewModelBase.cs, this provides the necessary code for messaging from the View Model to the View Persistence Classes which can be persisted using the facilities within IO Resources Resource files (yes, this application is localised SampleData Sample data XAML files so the designer view in VS2010 looks pretty. Scrambles Contains a single class to mix up the tiles in a puzzle SinglePlayer I'm not quite sure why this isn't in GameTemplates, it will be shortly! Test Ignore this, I never really got around to writing unit tests Toolkit.Content Created by the Silverlight Toolkit, I don't think I use this!

Techniques MVVM and Code-Behind

The pages of the application either use MVVM or are straight ASP.NET-style code-behind, the following table shows which one is which:

Page Purpose Style AddPlayer Adds or edits a player's name Code-behind CreateCustomGame Work in Progress – Allows the user to create their own set of levels MVVM (will be eventually) GameEnd Shown when the player finishes all the levels Code-behind GamePage The main page shown that has the sliding puzzle MVVM-kinda HighScores Shows the high score table MVVM ImageAreaChooser Work in Progress – allows the user to select an area of an image to use as a puzzle MVVM ImageChooser Work in Progress - allows the user to choose an image to play with from either a URL or local photos Code-behind MainPage Shows the menu structure (data driven menus so only 1 page required MVVM PlayerSelector Allows the user to select a player profile to use MVVM SaveGameSelector Allows the user to select a previously saved game to continue MVVM

Acknowledgements

Windows Phone Mango Jump Start - Rob Miles & Andy Wigley These (funny) guys hosted the Windows Phone Mango Jump Start videos, which provided me with a great start to understanding development on WP7.

Windows Phone Geek Windows Phone Geek provides countless useful articles on Windows Phone development. DelegateCommand came from here.

NLog for Windows Phone 7 - Jarek Kowalski NLog is an invaluable tool, it's used in this project for creating a debug trace.

Little Watson - Andy Pennell Little Watson allows bug reports to be sent back to me.

Your Last About Dialog - Peter Kuhn (Mister_Goodcat) Your Last About Dialog was used for the acknowledgements.

Windows Phone Silverlight Toolkit - Microsoft Lots of great utility classes that eased the development of this app.

WriteableBitmapEx - Various A very handy set of extension methods for the WriteableBitmap class.

MetroGridHelper - Jeff Wilcox Helped me to work out how to lay out my controls (although I've probably done it badly!)

Sandcastle - Eric Woodruff Sandcastle builds the HTML API documentation.

Scott Hanselman I was inspired to write this having read Scott's post on Shipping my first Windows App. He's a truly motivational speaker and writer!

Clone this wiki locally