Skip to Content

Category Archives: Code Bits

SQL Server XML

Written on September 13, 2010 at 2:21 pm, by

Apparently, since I last touched SQL Server they’ve added some pretty awesome XML support. SELECT SpecId as “@Id”, Name as “@Name”, Description as “Description” FROM tbSpecs FOR XML PATH(‘Spec’), TYPE; Returns XML straight out of SQL Server. The best thing? The “TYPE” clause on the FOR XML part makes it return as an XML data  Continue Reading »

Wisp Source

Written on August 10, 2008 at 2:59 am, by

Because Mykre couldn’t wait to see it, here’s the source code for the wisp demo I recently made. I cleaned up the code a bit and added pretty liberal comments so you can really tell what’s going on. Let me know what you think! Download the Source Code

Time Control

Written on August 1, 2007 at 12:20 pm, by

A quick note about time control, with code. XNA makes time relatively simple – a GameTime object is managed automatically and given to you every frame. This makes calculations involving time relatively simple. However, what happens when you want to slow down time? You could just use a variable to set the time speed, and  Continue Reading »

Eliminating Magic Numbers

Written on July 5, 2007 at 3:21 pm, by

With the Dream Build Play competition nearing a close, I’m sure everyone is busy with tweaking their game to make it as fun as possible. Of course, this can be quite the monumental task if you’ve got a large code base with “magic numbers” all over the place. What’s a magic number, you ask? A  Continue Reading »

WSUXNA Engine Code

Written on June 9, 2007 at 2:49 am, by

It’s about time I release the engine I created last fall in XNA. This engine is purely academic, and should be treated as such (i.e. don’t go trying to make your own games with it unless you want to retouch most of the engine). However, it’s fully commented, and I believe the code is both  Continue Reading »

QuadTree (Source Included)

Written on May 6, 2007 at 9:45 am, by

Enjoy this tutorial on Quadtrees, explaining how they work and why they’re useful for collision detection. Includes pictures and source code. Comments are highly appreciated. A Quadtree’s Purpose Your collision detection solution should operate at successively more accurate levels to be effective. Since each successive level is more accurate, deeper levels require more processing time.  Continue Reading »

Commenting is Easy!

Written on March 18, 2007 at 8:29 pm, by

I admit, I used to hate commenting code. It took so much time, and I was constantly changing the code anyway. Every time I’d code something, I said “I’ll comment it once it’s done.” Every time I finished something, I’d immediately start working on the next piece. After all, it took a lot of time  Continue Reading »

Code Snippets in XNA

Written on March 5, 2007 at 11:16 am, by

Do you find yourself typing the same thing over and over again? Maybe it’s the code to draw an effect (begin, end and the pass loop) or maybe you keep having to resolving a render target to a texture. Wouldn’t it be nice if you didn’t have to type all that code every time? Enter  Continue Reading »

HLSL is More Strict on the Xbox 360

Written on February 25, 2007 at 8:32 am, by

I ran into this problem recently, and I thought it would be a good point to note, especially for anyone who doesn’t have access to an Xbox but would like their code to work on one. When writing shaders, remember that the Xbox is more strict than a PC. Make sure your input parameters match  Continue Reading »

Sharing Code Between the Xbox 360 and PC

Written on February 22, 2007 at 8:43 am, by

Preprocessor directives! These enable you to define what code will or won’t be compiled, throw errors or warnings during compilation and mark regions of code for better organization. Here’s a short example of what I’m talking about: The code above will compile differently when built for the Xbox or the PC. In this example, when  Continue Reading »