Archive for the ‘Software Development’ Category

Friday, September 8th, 2006

Before I get started, I’d just like to point out that this snippet is not game development specific. It could be useful in any application.

Here we go then…

Lets say you have some asset, file, media, whatever that needs to be distributed with your application, and your application programatically loads it. You could just distribute it as a file in it’s own right, but you might like to consider embedding it in your exe.

Why?:

Convenience!!!

No need to copy this content to your Bin folder for runtime, debugging etc…

Minimise tampering.

What if it was your company’s logo, and people could tamper with the Image and change the branding of your application?
Or in the case of game development, you don’t really want your textures where cheaters can buggerize with them! You know, change the textures Alpha channel, so the entire texture is tranparent in the game.

Convinced? It’s very easy to do.

Add your content into your project.

Code Snippet - Embedded Resource Solution

In the files Properties change it to an Embedded Resource.

Code Snippet - Embedded Resource Properties

Now here’s a helper class for getting a Stream of the content.

 

using System;
using System.Text;
using System.Reflection;
using System.IO;
namespace MyProject.Helpers
{
    public class ResourceHelper
    {
        /// <summary>
        /// Returns a stream for the named embedded resource.
        /// </summary>
        /// <param name="nameSpace">The namespace containing the embedded resource. Case sensitive!</param>
        /// <param name="name">The filename of the embedded resource. Case sensitive!</param>
        /// <returns></returns>
        public static Stream GetEmbeddedStream(string nameSpace, string name)
        {
            Stream result = null;
            Assembly a = Assembly.GetExecutingAssembly();
            string resourceName = String.Format("{0}.{1}", nameSpace, name);
            result = a.GetManifestResourceStream(resourceName);
            return result;
        }
    }
}

Simply call the GetEmbeddedStream from your code passing the nameSpace & the name of the desired file.  (case sensitive)

e.g.

Stream myStream = ResourceHelper.GetEmbeddedStream("MyProject.Goodies.Images", "TheManWithTwoBrains.jpg");

Once you have a Stream you can use it with any class that lets you load from a stream.

That’s it! Enjoy. :)

Average Rating: 4.7 out of 5 based on 169 user reviews.

Thursday, September 7th, 2006

I’ve barely had time to look at XNA, but one of the first hurdles I’ve seen so far is loading a mesh in the traditional .x format.

In the past the DirectX SDK’s Managed DirectX libraries contained support for using the .x format. However XNA does not…well, not yet at least. XNA was supposed to include something called the “Content Pipeline”, which would have supported the .x format. However, at the last minute Microsoft held back on including the Content Pipeline. I guess it wasn’t ready for public consumption.

It does support some other format .swm, which appears to be propriatory. Until the Content Pipeline is released (hopefully soon), the work around seems to be to convert your .x format meshes into this .swm format.

I see over at XNA Spot that there is now a converter. It’s on their samples page. I haven’t tried it yet, but fingers crossed I’ll have the ol’ Spitty rendering real soon.

Oh yeah, and I have to learn HLSL too. That’s “High Level Shader Language”.

eeek!!! ;)

Average Rating: 4.8 out of 5 based on 178 user reviews.

Monday, September 4th, 2006

Howdy all.

I’ve been a bit slow on the blog front for the last few days.

Basically gaming too much in the evenings, with a pinch of procrastination mixed in.

In the weekend, I finally got the fancy new XNA stuff installed and started looking at the sample game.  Looks real nice, and the plumbing code looks a whole lot tidier than how my code has evolved as I’ve learnt stuff.  Helped by the fact that the XNA framework itself looks a lot cleaner than old-school Managed DirectX.

With that in mind, I’m definately going to migrate my code to use the XNA framework next. Pretty easy decision – would be dumb not to really.  Besides, it would basically make my game multi platform, Windows and XBOX 360.  I was about to refactor and tidy things up anyway.

So I’m back to basics for a bit while I learn how to write for XNA.

There is one catch with me migrating to XNA. 

Some of you with older/less fancy hardware (Video card)  may have difficulty getting an XNA version working at all.  This is because with XNA, microsoft have removed support for something called the “fixed-function pipeline”.  I’d never even heard of it until a few days ago (although I was probably using it!).  Basically they are looking forward and figuring game development has been moving away from this “fixed-function” thingy for some time.  So instead of bloating things with support for old-school stuff, they’re cutting clean and forcing us to do things the new and cool way. 

The new way is done entirely with Shaders!  Now I don’t know the first thing about Shaders, so I guess there’s another new thing for me to learn.

“How does that effect me?”, I hear you say…

Well basically if your video card doesn’t support Shaders (I think it’s minimum v1.1) then it’ll probably not work at all.    :(

Stay tuned for more as I learn more.

Average Rating: 5 out of 5 based on 298 user reviews.

Thursday, August 31st, 2006

Some of you (that have only seen the screenshots) have remarked that the bullets appear to have a circular motion.

So I’ll just squish that one right now!  ;)

Actually it’s not circular at all.  Every bullet flys straight and true.  The only reasons they appear at all circular in the screenshots is this:

  • the planes were turning while shooting, causing the bullets to spray out. Call it straffing. 
  • in my game you can actually see the bullets.  In real life you wouldn’t, because bullets travel too fast.  For my arcade style game, I would like you to see the bullets, and actually have a small but fighting chance of evading them.
  • I also didn’t take any screenshots with the planes holding steady and nailing the target.
  • Another thing that adds to the effect, is that there are two bullets per shot – one from each wing like the real Spitty. So you get a bit of a twisty effect between the two bullets, if the plane was rolling while firing. 

So there we go, then.  I hope that’s cleared THAT up!!!  ;)

p.s.  I’m considering adding a little gravity to the bullets actually.  It’ll be easy, and interesting to see how it affects the game play.

Average Rating: 4.5 out of 5 based on 279 user reviews.

Thursday, August 31st, 2006

Some people seemed to be getting the old version, because of nasty Proxy servers serving up an old cached build.zip.

Try again.  I’ve renamed the build.zip to build_20060830.zip now.

Average Rating: 4.5 out of 5 based on 243 user reviews.

Wednesday, August 30th, 2006

As promised the shooting is done! ;)

Latest screenshots

So what are ya waitin’ for? Give it a whirl damnit.

I’ve uploaded the latest build. Get it here.

And for a taster, check out more screenshots over here.

“Shooting…so HOT right now!”

Average Rating: 4.7 out of 5 based on 297 user reviews.

Wednesday, August 30th, 2006

I saw over at LetsKillDave that the FREE Visual C# Express IS going to be required if you plan to install Game Studio Express. Visual Studio 2005 would partially work, but it the integration and add-in templates will not. (not sure if this will be addressed later)

The blog is here, but the detail is in the comments.

In case you’ve been living in a cave, “Game Studio Express” is the free IDE for developing with the new XNA framework. It is being released today/tomorrow depending on your timezone!!!

In the words of Stimpy “I can hardly contain myself!” :)

Average Rating: 4.7 out of 5 based on 239 user reviews.

Monday, August 28th, 2006

The XNA Team Blog has some great new info over here about what we’ll see in XNA (which comes out any day now…for FREE!!!)

Check this out…

“… Our goal is for you to be able to start writing your game within the first 5 minutes of starting a project. You won’t have to worry about creating a window. You won’t have to worry about a message pump or an Idle event. You won’t need to enumerate graphic adapters and display modes. You won’t have to create a Direct3D 9 device and manage it when the window is resized or the game is minimized. The XNA Framework takes care of all those things for you. The first thing you do is write code for your game. …”

FAN-FREAKN-TASTIC!!!

Initialising the Device has probably been the hardest part of getting started with game dev. I know I’m still not doing it properly – hence the lengthy troubleshooting section on getting the game to actually run.

I’m elated that soon I shouldn’t have to invest any more time on that complicated aspect of game dev. ;)

There is plenty more to drool about, so read on.

Average Rating: 4.4 out of 5 based on 221 user reviews.

Monday, August 28th, 2006

…but my brain hurts.

Doing the bullet particle system was fun, but what I had thought would be the simplest part (actually rendering the bullets) ended up taking me the whole dang evening!!!

Unforseen complications – I’ll explain later.

It’s not quite ready for public consumption yet, but real soon you’ll be able to shoot at…well…nothing in particular..yet. 

You get what you pay for, right!

Average Rating: 4.4 out of 5 based on 284 user reviews.

Wednesday, August 23rd, 2006

Due to popular demand (and JD’s nagging).

I’ve changed my mind and will work on adding some SHOOTING to the game next.  Not that there’s anything to shoot AT yet, but it’ll be fun.  Besides, it will shut JD up for a bit.

I’ll leave the refactoring till later because I’ll have a lot of refactoring to do when XNA comes out anyway.

I started looking at some elegant little Particle System samples last night.  Remarkably similar to my self-written CloudManager classes actually, so quite chuffed about that! :)     

Anyway,  the idea cauldron is bubbling away nicely, so stay tuned.

Average Rating: 4.8 out of 5 based on 271 user reviews.