My Delving into XNA – Part I

Posted: May 2, 2011 in Game Programming and Design

I got into software development when I was younger because I wanted to write video games.  That never quite panned out, but I was left with a useful skill of being able to write code and then later database code to make programs.  This is how I make my living today.

I’ve had several projects stewing in my brain for a long long time.  One of them is a war campaign game kind of like Total War only with fantasy elements.  Now, I am no graphics artist.  This means that I have to struggle within my means.  I am adept at Photoshop and can make some decent 2D sprites but 3D modeling and the like is currently beyond me.

This wargame of mine would therefore mainly be 2D top-down and turn based.

I am delving into the XNA architecture to help me write this game for windows/xbox.  XNA is a foundation and framework for developers to use to develop windows based and XBOX games.  The blog here will detail my learning the structures of XNA and writing some basic games in it.  I am looking forward to it as in the end I will be able to start work on my wargame and hopefully one day take over the world and surrounding suburbs.

Some interesting objects and what not for me to learn and remember:

Content Pipeline – the main framework that lets me load media.

Textures – these objects load and store image file data.  Images with transparency are best used with png and tga files.  Texture objects are referenced when drawing an image to a window.  The object in C# that holds these are called Texture2D objects.

It is recommended that within the solution explorer of Visual Studio 2010 that I create an Images subfolder under my Content node, and I have done so.

The first example that I am going to build is a simple spaceship game that you may have had fun with in the 80s.  Asteroids was a lot of fun on the Atari back in the day, and now I am going to recreate my own version of it.  There are two image files that I pull… asteroid.tga and ship.tga which are supplied by the book that I am using.

LoadContent() Method – the LoadContent() method is where we load all of our media into memory.  You know how when you launch a video game, you usually get a loader window which makes you wait?  The game itself has to load all of its sounds and images into memory first.  We are instructed to never reference our images with their extension or we will not be able to get a successful build.  Just a tidbit to remember =)

As I have two images so far (a ship and an asteroid) I code them into the LoadContent method as such:

Texture2D textureShip = Content.Load<Texture2D>(“Images\\ship”);
Texture2D textureAsteroid = Content.Load<Texture2D>(“Images\\asteroid”);

My next post will deal with working with spritesand how to animate them…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s