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

    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

    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

    Spawning More Enemies (TriangleShooter)

    • 0 Comments

    Time for my favorite part of Monday – Another article improving my TriangleShooter game! Last week, I promised you that I would spawn some more enemies, and that I would add in some other enemy types to make it more visually appealing. The great news is, both of those things are pretty easy. We’ll get started with the code base from last week, so you can grab that from my SkyDrive share.

    We can start by adding in some additional enemy types. To begin with, we’ll drag and drop the rest of the Enemies from the Enemies file from SkyDrive into the Content project with the first enemy. We’ll then create some variables to hold the textures.

    Textures for Enemy
    1. Texture2D txEnemy3;
    2. Texture2D txEnemy4;
    3. Texture2D txEnemy5;
    4. Texture2D txEnemy6;

    We’ll then load them from the content project in the LoadContent method.

    Loading the Enemy Textures
    1. txEnemy3 = Content.Load<Texture2D>("Enemy-3");
    2. txEnemy4 = Content.Load<Texture2D>("Enemy-4");
    3. txEnemy5 = Content.Load<Texture2D>("Enemy-5");
    4. txEnemy6 = Content.Load<Texture2D>("Enemy-6");

    We can try this out by changing the lines further down in LoadContent to make use of the new textures.

    Creating Diverse Enemies
    1. enemies.Add(new Enemy() { Avatar = txEnemy3, Position = new Vector2(600f, 200f), Rotation = 0f, Speed = 3f });
    2. enemies.Add(new Enemy() { Avatar = txEnemy4, Position = new Vector2(600f, 300f), Rotation = 0f, Speed = 3.5f });
    3. enemies.Add(new Enemy() { Avatar = txEnemy5, Position = new Vector2(600f, 400f), Rotation = 0f, Speed = 4f });

    image

    Next up, we need to start spawning some more enemies. What we’re looking to do here is to bring in new enemies every so often. The faster you spawn the enemies, the more difficult the game would be, so you can play with the amount of time between spawns. In order to track them, though, we’ll need a variable to track how long we have left until the next spawn. Since we’ve got some different enemy types, we may as well add in some randomization, so we’ll create a variable to handle randomness as well. As always, we’ll drop the variable up at the top of the game file.

    Spawn Timer and Randomization
    1. TimeSpan timeToSpawn;
    2.  
    3. Random random;

    And then we initialize them down in Initalize()

    Initializing Spawn and Random
    1. timeToSpawn = new TimeSpan(0, 0, 0, 0, 1000);
    2.  
    3. random = new Random();

    This sets up timeToSpawn as one second. We’ll count down until this reaches zero, then spawn another enemy. Luckily, there’s a easy way to get elapsed game time in the Update Method with the gameTime argument. We’ll subtract the elapsed game time from the timeToSpawn variable, then check to see if it is less than or equal to zero. If it is, we create a new enemy and add it to the enemies list. To add variety, we can pick a random edge, and spawn the enemy somewhere along it so that it doesn’t just always come from the same spot. Finally, we’ll reset the timeToSpawn so that we can spawn another. All of this will go in the Update method after we check the enemy collision.

    Spawning More Enemies
    1. timeToSpawn -= gameTime.ElapsedGameTime;
    2.  
    3. if (timeToSpawn < TimeSpan.Zero)
    4. {
    5.     Vector2 spawnPosition;
    6.     switch (random.Next(4))
    7.     {
    8.         case 0:
    9.             spawnPosition = new Vector2(0, random.Next(480));
    10.             break;
    11.         case 1:
    12.             spawnPosition = new Vector2(800, random.Next(480));
    13.             break;
    14.         case 2:
    15.             spawnPosition = new Vector2(random.Next(800), 0);
    16.             break;
    17.         case 3:
    18.             spawnPosition = new Vector2(random.Next(800), 480);
    19.             break;
    20.         default:
    21.             spawnPosition = Vector2.Zero;
    22.             break;
    23.     }
    24.  
    25.     switch (random.Next(4))
    26.     {
    27.         case 0:
    28.             enemies.Add(new Enemy() { Position = spawnPosition, Rotation = 0f, Avatar = txEnemy3, Speed = 3f });
    29.             break;
    30.         case 1:
    31.             enemies.Add(new Enemy() { Position = spawnPosition, Rotation = 0f, Avatar = txEnemy4, Speed = 3.5f });
    32.             break;
    33.         case 2:
    34.             enemies.Add(new Enemy() { Position = spawnPosition, Rotation = 0f, Avatar = txEnemy5, Speed = 4f });
    35.             break;
    36.         case 3:
    37.             enemies.Add(new Enemy() { Position = spawnPosition, Rotation = 0f, Avatar = txEnemy6, Speed = 4.5f });
    38.             break;
    39.         default:
    40.             break;
    41.     }
    42.  
    43.     timeToSpawn = new TimeSpan(0, 0, 0, 0, random.Next(500) + 250);
    44. }

    image

    There’s just so many of them!

    Next week, we’ll add in shooting! Until this point, we were just a triangle moving around, but now we’ll finally be a triangle that shoots!

    Download the latest version of the source code.

Page 3 of 8 (37 items) 12345»