Posts
  • File → New Project

    Windows 7 Beta

    • 0 Comments

     

    Windows_7_build_7000 It turns out I wasn’t the only person out there who was excited to get access to the Windows 7 beta when it hit last Friday. I checked the site over and over during the day, waiting for a download link to appear, but headed home before it did. That night, when I got home, I figured the download had to be available, and I would be able to grab a copy overnight. No such luck. The beta was so popular, the servers couldn’t keep up with the demand, so they had to take down the links. There were people out there running the beta now since it hit BitTorrents, a number of my friends included, but I couldn’t get a copy. I scoured some message boards for news about the beta, and came across a site where a commenter posted the .iso links directly. I checked them out, and they were Micrsoft.com urls, so I tried them out. Sure enough, they were good, and I was downloading. Further down the page, someone had posted a comment linking to the page on Microsoft’s site where you could get assigned a CD-Key, with the recommendation that you sign in to live through another service to make sure you get in. I tried it out, and there was my key. I was good to go.

    I installed first on my wife’s new netbook. She had been using her laptop for some years, and it was needing replacement. I visited a friend’s place a while back, and he told me about how he had just picked up the MSI Wind u100, and told me about the comparisons that he had done with some other netbooks, and showed me how he had upgraded it to 2 gigabytes of RAM, and everything it could do. I trust this guy when it comes to computers, so when I got home, and found out that it came in pink, I ordered one on Amazon. The interesting thing about installing on the netbook was that it didn’t have a DVD drive. I’ve got some links at home that I’ll post a bit later, but the basic process I used was to take a 4 GB thumb drive, format it for NTFS, used bootsect to make it bootable, then copied the contents of the Windows 7 .iso onto it. The netbook booted straight from the thumb drive, and I was off. The install was extremely clean, and because a thumb drive is so much faster than a DVD drive, the install even benefitted from the whole process. Next, I installed onto my home desktop. This one was a bit more straight-forward. Just burned the x64 .iso and installed from the DVD.  MSI Wind

    I’ve been using the beta since then, and things are going great. I’ve posted some feedback to the Windows team through the links on all of the windows, but they’ve mostly been little things like the mismatching case in HomeGroups and homegroups. I worked tech support and wrote user manuals for a product I worked on in my first development job, so I get a little obsessed about those things. I have to fight not to highlight errors in tech books I read through.

    Most applications have run without a problem. I did run into a problem with Skype, but it was actually just a popup that came up when I was running the install that told me that it wasn’t going to work, so I should download the latest beta. I did, and it worked fine. Another thing I ran in to was getting my phone connected to it. I have a Blackjack II that is really particular about how it charges off of USB, and unless it is recognized, it won’t take juice from the port. I plugged it in, and the driver tried to install, then failed. I looked around for some information on it, but couldn’t find any, so I just tried installing the Windows Mobile Device Center for Windows Vista x64, and it suddenly found my phone and everything worked great. The final thing I ran in to was a problem with Live Mesh. I use it a lot, so I couldn’t be without it on any machine. I even got it on my phone (They just expanded the CTP), but on Windows 7, Live Mesh didn’t play well with Aero. Turns out there was a fix for it ready, but it was being held off of until the holiday freeze on new installs was off. It should be available tonight. I’ll let you know how it works.

    Update: The site with the process I followed for creating the USB drive installer is at http://kmwoley.com/blog/?p=345

    Live Mesh has been working great with the new update, though I did have some problems remoting into my 7 desktop from my Mom’s place over the weekend, but I think it may have been in part because her internet barely qualifies as broadband.

  • File → New Project

    Windows Phone SDK 7.1.1 Update released today

    • 0 Comments

    imageAs I was putting together some final materials for our upcoming series of DevCamps for Windows Phone, I noticed that the Windows Phone 7.1.1 Update is available as of today. The update allows developers to test on a new emulator running with 256 MB of RAM, and also lets you develop using the emulator under Windows 8. Of course, since Windows 8 is still in a pre-release form, it’s still not an officially supported scenario, but I am going to give it a try for sure.

    You can read more about the release on the Windows Phone Developer Blog, and download the update from MSDN.

  • File → New Project

    Persisting the High Score Between Games (TriangleShooter)

    • 0 Comments

    Last week, we added scoring, and keeping track of the high score over a set of games. The problem is, when you exit the game for any reason, you lose your high score. That’s because everything is unloaded from memory, so when you start your game over, it has nothing to start from. This week, we’ll save your high score to a file, so we can load it back up when you restart your game. To begin, we’ll load the code from last week over at the SkyDrive Share.

    When working with files, we’ll need to add a few libraries. On the Windows Phone, applications have access to a special type of storage called IsolatedStorage, which is a file store that is accessible only by your application. Additionally, we will be storing our high score in an XML format, and accessing it with LINQ. To work with these, we’ll the following three include statements:

    Using Statements
    1. using System.IO;
    2. using System.IO.IsolatedStorage;
    3. using System.Xml.Linq;

    Once we’ve got these, we’ll just need to set up two simple methods. We simply need to save to the file, and load from the file. We’ll then just need to update the game to call the load method when it starts, and the save method at the end of each game.

    SaveToFile
    1. public void SaveToFile()
    2. {
    3.     string fileName = "SavedState.xml";
    4.  
    5.     using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
    6.     {
    7.         using (IsolatedStorageFileStream writeStream = new IsolatedStorageFileStream(fileName, FileMode.Create, store))
    8.         {
    9.             using (StreamWriter writer = new StreamWriter(writeStream))
    10.             {
    11.                 XDocument doc = new XDocument(
    12.                     new XDeclaration("1.0", "utf-8", "yes"),
    13.                     new XElement("State",
    14.                         new XElement("HighScore", highScore.ToString())
    15.                         )
    16.                      );
    17.  
    18.                 writer.Write(doc.ToString());
    19.             }
    20.         }
    21.     }
    22. }

    At the beginning of the SaveToFile method, we choose a file name to save the game state. You then open the Isolated Storage and open a file stream into it. We use FileMode.Create because we just want to overwrite a file if it’s there, and make a new one if it isn’t. The StreamWriter lets us write directly into the file we created in Isolated Storage. We then create a basic XML file that contains the high score inside of a State element.

    LoadFromFile
    1. public void LoadFromFile()
    2. {
    3.     string fileName = "SavedState.xml";
    4.  
    5.     try
    6.     {
    7.         using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
    8.         {
    9.             using (IsolatedStorageFileStream readStream = new IsolatedStorageFileStream(fileName, FileMode.Open, store))
    10.             {
    11.                 using (StreamReader reader = new StreamReader(readStream))
    12.                 {
    13.                     string stateXml = reader.ReadToEnd();
    14.  
    15.                     XDocument doc = XDocument.Parse(stateXml);
    16.  
    17.                     var q = from c in doc.Descendants("State")
    18.                             select (string)c.Element("HighScore");
    19.                     
    20.                     int i = 0;
    21.  
    22.                     foreach (string s in q)
    23.                     {
    24.                         if (int.TryParse(s, out i))
    25.                         {
    26.                             highScore = i;
    27.                         }
    28.                     }
    29.                 }
    30.             }
    31.         }
    32.     }
    33.     catch (IsolatedStorageException)
    34.     {
    35.     }
    36. }

    To load from the file, we use the same file name we defined when we saved our state. We then open the Isolated Storage using a StreamReader, and load its contents into a XDocument. This lets us use LINQ to pull in the elements that we saved. We walk through the elements named HighScore, and parse its contents into the highScore variable. The whole thing is wrapped in a try catch block because the file might not be there, or maybe there is something wrong with the file. We don’t want that to crash the game, so we just let it go.

    Now we need to use these methods. First of all, we just need to load in the file in the Initalize method.

    Initialize
    1. protected override void Initialize()
    2. {
    3.     random = new Random();
    4.  
    5.     highScore = 0;
    6.  
    7.     LoadFromFile();
    8.  
    9.     base.Initialize();
    10. }

    And finally, we need to save it. You could put it in every time the high score is beaten, but file I/O is expensive, so this could cause performance problems. Since we are really storing game high scores, why not drop it into the update method when the player dies.

    Code Snippet
    1. if (new Rectangle((int)enemy.Position.X - enemy.Avatar.Width / 2, (int)enemy.Position.Y - enemy.Avatar.Height / 2, enemy.Avatar.Width, enemy.Avatar.Height).Contains((int)player.Position.X, (int)player.Position.Y))
    2. {
    3.     triangleColor = Color.Red;
    4.     isPlayerDead = true;
    5.     SaveToFile();
    6. }

    And there you go, your high score is saved across application launches. Remember that if you restart the emulator, your isolated storage will be blown away, so you’ll lose your high score. This will also happen in you uninstall the game and then redeploy.

    Next week, we’ll be adding sound effects, so stay tuned.

    Download the latest version of the source code.

  • File → New Project

    You've Got Game Sweepstakes for Game Developers

    • 1 Comments

    game

    You still have time to get your game into the You've Got Game Sweepstakes before the February 29th deadline. For every game you create and publish a to the Windows Phone Marketplace, you get another entry for a chance at winning a Dell Alienware M18x laptop or an Xbox LIVE Gold Card.

    Head over to http://aka.ms/ygg to find out more about the contest, how to enter, and what you can win. Rules are at http://bit.ly/YGGRules

  • File → New Project

    Building a Language Learning Game (QuizGame)

    • 1 Comments

    This week we’ll be starting a new game for the Windows Phone. We’ll be using Silverlight this time around, and building a language learning game. The idea behind the game is to make use of a database of words and meanings, pick a word, and give four possible definitions. I actually originally built the first version of this game in XNA, and when I redid it in Silverlight, the implementation ended up being much easier. This week, we’ll start with a new Silverlight project, and walk through what that gives you. We’ll also look at a source of graphics we’ll be using for the game.

    To begin with, load up Visual Studio 2010 Express for Windows Phone, and choose File –> New Project, and under the Silverlight for Windows Phone templates, choose Windows Phone Application. In the Name field, type QuizGame, then click OK. You’ll get a new solution containing a single project with a few files. The basic structure a Silverlight application is a set of XAML files, containing markup that defines the user interface, and .cs files with code behind. In the MainPage.xaml file, you’ll get a visual desginer with a few elements in it. The layout is done through a Grid element containing a StackPanel with two TextBlocks. When you run the application, the emulator will pop up and display the application, looking something like the following:

    QuizGame

    The numbers on the right of the page is a frame rate counter. You can turn it on or off using the following line in the App.xaml.cs file’s constructor.

    Enabling the Frame Rate
    1. Application.Current.Host.Settings.EnableFrameRateCounter = true;

    The other important files in the project are the ApplicationIcon.png file, the icon that will appear in the list of apps on the phone, Background.png, the image to display when your application is "pinned" to the Start screen, and SplashScreenImage.jpg, the splash screen that will be displayed when you launch the application.

    We’ll be getting deeper into the XAML next week when we lay out the user interface. This week, we’ll finish off by looking at the source of images we’ll be using. There’s a great resource over at http://www.lostgarden.com/ where an artist occasionally posts sets of graphics like the one we will be using. The post in question is Danc's Miraculously Flexible Game Prototyping Tiles.

    Here’s an example of the type of graphics we’ll be using.

    Character Cat GirlCharacter Princess GirlSpeechBubble

    StarGem GreenGem OrangeHeart

    See you next week, when we’ll set up the game interface.

Page 3 of 8 (37 items) 12345»