Windows Phone 7: AI, Pathfinding and working with the images

,

I like to play games against game artificial intelligence, mainly because I hate getting my posterior kicked in Halo Reach by a 12 year old.  In fact I don’t even like to game with anyone under 18, not because they aren’t worthy competitors, but our society has set up pretty strict safety zones around younger adults.

For many people, playing against an AI, for instance, Solitaire, is the way they like to play games.  This is the importance of the PathFinder example, it allows you to add AI to your game.  Also, AIs add a nice spice to social networked games.

In the previous blog, we discussed how to modify the appearance of the “game” using the XML file.  This is sometimes referred to as a presentation layer.  In a more complex way, XAML is just like the XML for PathFinder, except the XAML used with Silverlight projects controls the user interface.  Oh wait, so does the XML in the PathFinder.  How? The XML file in the Pathfinder places the blocks and where the “avatar” starts on the game.  XAML is somewhat smarter, but unless you want to do tricky XAML code then generally XAML nor the XML in PathaFinder will generate a “program” it will only tell the program how to present the User Interface.

Before we get to the code, let’s make sure you can work with the images.  This is a review for the folks who have been following this worthless blog, likely to find out how to not write a blog.  Let’s face it, successful blogs only contain links to information and follow Mel Gibson, Lindsay Lohan or some other celebrity with abuse problems.

 

To keep this real simple, you will need to change the Asset Name from tank to tank1:

image

 

Add a png (it can be jpeg if you want) that is 64X64 pixel size file, you can size the image using Paint.NET or Paint (the one included with Win7).  I added a png file called santa.png and then changed the asset name to tank.  Doing this may seem confusing right now, but it will make sense later.  Your file name may be different, but the asset name must be tank for this to work.

image

Now run your PathFinder and it should look like this (if you used Santa(1).png for your avatar):

image

Santa is located at start position 0,0 in the image above.

In the image below, Santa is located at start position 0,1 in image below:

image

That’s it for today.

 

NNNN