More servicesWindows Live
HomeHotmailSpacesOneCare
 
MSN
Sign in
 
 
Spaces home  Nathan Levesque - Develo...ProfileFriendsBlogMore Tools Explore the Spaces community

Nathan Levesque - Developer/Designer

Developer/Design Blog
May 15

The Key is Back in the Ignition

So to speak. I've decided to separate XNA content back out to this blog again. Partly because I want separation of content and partly because the other blog is now being aggregated by sites that do not cater to XNA. More to come. Using the XNA 3.0 CTP.
October 07

Relocation

OK, so if you have wondered why this blog has been mostly inactive for a while that is for two reasons: (1) I simply haven't had the time to work with XNA that I wish I had and (2) I've been working on getting my personal site set up so I can begin posting there instead of here.

So, turn your browsers to:

nathanlevesque.com

All content already here will remain and may be reposted on my site in a more formal tutorial format in the future.
August 20

Scratch That

Ok, so after some of the interesting developments in XNA over the last few weeks I guess I just can't keep myself away from it. With the release of the new XSI Mod tool I have considered resuming my game development. The primary problem for me in the past was that there was no free 3d package that offered me everything I needed (working UVs, animations, and an easy to use UI). Also, the announcement of the networking APIs for the 360 has me excited as well. Although I don't presently own one, this may very well be the impetus (and excuse) I need to purchase one. However, that will come after the successful development of a PC game.

So for now, I'm back with XNA, although I will still be doing ASP.NET and other general .NET stuff in addition to it.

August 01

Change of Course

It's been almost a month since the Dream-Build-Play contest ended and I regrettably was unable to finish my entry to a satisfactory quality in order to submit it on time. However, I would like to congratulate everyone who was able to get their entry in as I have seen many games shown over the last few weeks that I think show much of the effort and determination the XNA community has.

Since then, I've had to make a difficult decision to change course on the subject of this blog. I am by trade a web designer/programmer but I like to sample other technologies such as XNA on occasion. I love what Microsoft has done and is continuing to do with the XNA platform but for me it is time to focus on more career-specific goals and this blog is not exempt. I simply do not have the time to focus on continuing to develop career skills and also participate in time-expensive hobbies such as XNA.

However, I do not believe my time spent on XNA has been in vain. I have learned much more about game programming in the last few months than I have in the last few years. I have also been able to learn an entirely new programming language, C#, in a matter of 6 months, whereas it took me 6 years to develop my C++ skills to the same level. As a result I've taken on learning ASP .NET which has simply continued to amaze me as to the relative ease of development. My C# skills carry over to this and I am beginning to see my skills build upon each other and expand at an increasing rate.

In summation, I'm going to be focusing primarily on ASP .NET news and information and showcasing some of my projects on that front. I will continue to keep an eye on the XNA community and occasionally post items of interest. I would like to return to XNA at some point in the future but at present its best for me to be an observer.

I will keep previous posts here for continuity for the community. If at any point anyone has questions or comments about the XNA-related content on this blog don't hesitate to do so as I will continue to respond.

Thanks to those who have supported me thus far. :)

June 14

Back in the Running

Ok, so I've taken the last week to get used to my new Vista computer. So far I love the new operating system and can't wait to get some DX10 games (played the DX10 PC demo of Lost Planet today and it was absolutely great). I'm getting excellent framerates on all of the games I already own too.

In the meantime I'm working on yet another rewrite of my game engine. It's getting a little ridiculous to keep rewriting every three weeks or so but I think this is a very robust version. Today I coded my own implementation of the GameScreen idea and integrated it with a post processing batch class. My post processing framework has the ability to basically render any object that implements a interface that has only a Draw method.

I'm not sure if I'm going to finish my game in time for the Dream-Build-Play contest deadline, but I'm going to try my best to at least have something remotely playable to submit. ;)

June 02

Update

Ok, so at present I am waiting until Monday until the parts arrive for me to assemble a new Vista PC for me. This has been a long time coming and frankly I don't know how I'm going to make it through the weekend since UPS doesn't deliver on the weekend and the package will be sitting not an hour's drive away from here for the next two days!

Since my development of my XNA game is on hold until that PC is up and running ( mostly cause I'm sick of developing on 6-year-old DX8 hardware), I've decided to make myself a little project for the weekend and that is the beginnings of a physics component. I've seen this requested on the XNA forums and my plans are that if I get this working and it is somewhere near publishable I will release both source and assemblies for the public to download. As such, I'm taking my time and trying to comment and document as much as I can while still making reasonable progress.

So far what I've got going:

  • Active and passive rigid bodies. These are presently held in a custom collection I designed to make handling rigid bodies easier. Actual collisions have yet to be coded. Planning on adding support to use any combination of: BoundingSpheres, BoundingBoxes, and Models to handle collisions. First two will be easy, Models not so much.
  • Extensible fields system such as gravity, vortex, wind (keeping it simple for now, these are relatively simple to add).
  • Some kind of dynamic system will be added later on for springs and such.

I hope to have a video demo up tomorrow night since I'm going to implement some simple BoundingBox collisions first and see how that goes.

Keep an eye out for it ;)

May 21

Matrix Tutorial

Not gonna post it in full here cause I'm lazy but I submitted an article at Ziggyware's

Introduction to Matrices in XNA

Understanding matrices is a fundamental part of creating effective games in XNA. Matrices particularly flex their muscle when you're working in full 3D space, however, the math behind them can be daunting. Fortunately, XNA provides most of the functionality for matrices that you will ever need without having to worry about the complicated math behind that functionality. However, it is necessary to have an understanding of what this functionality is actually doing in order to apply it correctly in your code. This article is rather long winded, but I'm trying to give a thorough explanation which will allow you to fully grasp the power of matrices.

Also I've been rather busy lately with my code, I've once again changed my mind on what I intend to do (I've been working on developing the basics of an engine so far, not worrying about content yet). I'm back to working on an RTS game since I don't feel like dealing with FPS code at the moment.

April 26

XNA Refresh Trick #1: Autoformatting Multiple Lines of Text

So by now everyone is very happy I'm sure of the release of XNA Refresh. It comes with a slew of additions to the framework that everyone has been clamoring for. Particularly font, 3d audio, and Model vertex reading support.

I've been putting off my GUI because I didn't want to redesign once the XNA team's font support came out, here's the first trick I created, to help myself with my GUI: autoformatting multiple lines of text. If you look into the documentation it says that the new text functionality will go the a new line with the text if the '\n' character is found. However, this makes for some static game design. What if I want the text block to be wider? Well, the way to do this is to add '\n' characters at runtime. Here's the little method I developed to do this:

public static void SetTextWidth( ref string text, SpriteFont spriteFont, float width )
{
    // get a vector representing the size of our string
    Vector2 textSize = spriteFont.MeasureString( text );

    // if text already fits, don't do anything
    if ( textSize.X < width )
        return;

    // remove existing newline chars in case it has already been formatted
    text = text.Replace( "\n", "" );

    // loop through all characters in string, if a character extends past our width
    float lineTotal = 0;
    float wordTotal = 0;
    int charCount = 0;
    int i = 0;
    do
    {
        // if we find whitespace, we're reached the end of a word
        if ( char.IsWhiteSpace( text, i ) )
        {
            // measure the length of the word
            wordTotal = spriteFont.MeasureString( text.Substring( i - charCount, charCount ) ).X;
            // if the word extends past our width, we insert
            // a \n before the word to pop it to the next line
            if ( ( lineTotal + wordTotal ) > width && lineTotal != 0 )
            {
                text = text.Insert( i - charCount, "\n" );
                lineTotal = wordTotal;
                charCount = 0;
            }
            // otherwise the word fits on our current line
            else
            {
                lineTotal += wordTotal + 1;
                charCount = 0;
                i++;
            }
        }
        else
        {
            charCount++;
            i++;
        }             
    } while ( i < text.Length );
}

Now this method isn't entirely robust, for instance it won't hyphenate words that are too long to fit on a single line, instead it just prints the whole word out, extendeding past our designated width. Feel free to change this, but for my case I wasn't concerned about being able to print 30 character words correctly (and I hope, netiher are you for your gamer's sake ;) ).

Here's a little preview of the results I can get with this method(single string used):

April 24

XNA 1.0 Refresh Update Released!

The XNA Team announced the release of their Refresh update for XNA today:

http://blogs.msdn.com/xna/archive/2007/04/24/xna-game-studio-express-1-0-refresh-released.aspx

I've only taken a cursory glance at the changes they've made, and needless to say I'm very pleased. I've already been able to make changes to my code that I've been waiting for this update to make. Particularly of interest to, and many others are the inclusion of text drawing and 3d audio!

I'd also suggest taking a good look through the docs, there's a lot of new topics, particularly in the "Programming Guide" section.

So, with the addition of the text drawing methods, I'm off to resume work on my GUI!

Thank you XNA Team for all your hard work!

April 16

A Better GetService

Ok, so recently there's been a lot of major discussion on the XNA forums about GameComponents. Now, I love the idea of having integrated components that automatically get get updated and also drawn in the case of DrawableGameComponent, however, when it comes to accessing the Game class's Services. I also have at issue being able to access said Services in a class that is not a GameComponent. I understand the XNA's team for making the services the way they are, however I don't want to have to derive from GameComponent and add it to the GameComponentCollection every time I want to check to have access to the ContentManager or whatever. For the most part, input components are the only issue that I have with the way Services are set up.

This simple class helps both Component and non-Component classes alike. Now, what this code avoids is having to type code like this every time you want to access a Service:

ContentManager manager = (ContentManager)Game.Services.GetService( typeof( ContentManager ) )

That can quickly become time consuming and can add to the illegibility of the code, not to mention either having multiple lines of code for one call or having to scroll horizontally a bit. So what I've decided to do is create a simple static class that stores the current game and has a generic method called GetService that functions similarly to Services.GetService():

public static class Component
{
public static Game Game;

public static void SetGame( Game game )
{
Game = game;
}

public static T GetService<T>()
{
return (T)Game.Services.GetService( typeof( T ) );
}
}

Now, what we do is call Component.SetGame(this); in the Initalize method of our derived game class (Game1 in a new project). Then every time we need a service in a non-component class, we simply call:

ContentManager manager = Component.GetService<ContentManager>();

Now this might not be the most elegant solution, but it appears to work well enough in my code.

View more entries
 
Thanks for visiting!
View space
ZhangPeng
View space
Jesse
View space
XNAIreland
View space
len
View space
Secret Paradise