This user hasn't shared any biographical information
Another Page for Project Shift
Posted in Project Shift, XNA 4.0 on October 10, 2011
It’s been a while since my last video, but it was definitely time away well spent; this is the latest with my Project Shift. The game engine is running very smoothly, and as you can see in the video, I’ve added some fun and interesting things–hint hint, elevators, mine carts, and explosive needles.
Enjoy the video, and as always, feel free to leave some feedback.
Number Display
Posted in Garbage Collector, Uncategorized, XNA 4.0 on August 13, 2011
In my previous post, I mentioned a Number Display that I had created in order to display numbers to the screen without creating any garbage. I thought some people might find it useful, so here it is. It’s relatively simple. You initialize it with a GraphicsDevice, SpriteFont, and some magnitude to define the general size. The Number Display will then create a number palette to be used in displaying the numbers. To draw a number, use the Draw(…) function passing in the number you want to display. The Number Display will finally use a Spritebatch to draw all of the different digits from the palette. Since no strings are used, no garbage is created.
public class NumberDisplay
{
GraphicsDevice drawDevice;
SpriteBatch drawBatch;
Texture2D numberTex;
Rectangle[] aryNumberRects = new Rectangle[10];
public NumberDisplay(GraphicsDevice newDevice, SpriteFont newFont, int digitMagnitude)
{
drawDevice = newDevice;
drawBatch = new SpriteBatch(drawDevice);
int rectSize = 2 * digitMagnitude;
RenderTarget2D newRender = new RenderTarget2D(drawDevice, 10 * rectSize, rectSize, false,
SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
// Create draw rects and texture map
drawDevice.SetRenderTarget(newRender);
drawDevice.Clear(Color.Transparent);
drawBatch.Begin();
Vector2 digitDim;
for (int i = 0; i < aryNumberRects.Length; i++)
{
digitDim = newFont.MeasureString(i.ToString());
aryNumberRects[i] = new Rectangle(i * rectSize, 0, rectSize, rectSize);
drawBatch.DrawString(newFont, i.ToString(), new Vector2(
aryNumberRects[i].Center.X, aryNumberRects[i].Center.Y), Color.White,
0.0f, Vector2.Zero, rectSize / Math.Max(digitDim.X, digitDim.Y), SpriteEffects.None, 0.0f);
}
drawBatch.End();
drawDevice.SetRenderTarget(null);
numberTex = newRender;
}
// ***** ACCESSORS *****
public Texture2D NumberPalette { get { return numberTex; } }
// ***** USER METHODS *****
public void Draw(int drawNum, Vector2 drawPos)
{
int drawDigit = drawNum;
drawBatch.Begin();
do
{
drawDigit = drawNum % 10;
drawBatch.Draw(numberTex, drawPos, aryNumberRects[drawDigit], Color.White);
drawPos.X -= aryNumberRects[drawDigit].Width;
drawNum = drawNum / 10;
} while (drawNum > 0);
drawBatch.End();
}
}
More on the Garbage Collector
Posted in Garbage Collector, XNA 4.0 on August 13, 2011
Pooled Objects
I had been meaning to come up with some sort of number display so I can write numbers (like the amount of Garbage) to the screen without worrying about it creating garbage. Well, I finally got around to it, and low and behold, my GC came to a complete halt. At first, I wasn’t so sure–perhaps my new number display was a bit off–so I threw in a couple lines that would specifically create garbage. Sure enough the GC kicked right back up again.
As you can imagine, I’m very happy. Now I can know what, exactly, is causing garbage the second I add it in. And already I’ve realized that I was wrong in thinking every class object that is added to a list creates garbage; it doesn’t! When I added those lines to test my display, I apparently had made an error. I added some class objects to a list that were from my already created pool of objects. The problem was that I still wasn’t seeing any garbage. I got a little worried because I figured that that meant there was a bug in my number display, but after a few minutes, I discovered the error.
Rather than adding objects from my pool, I added some newly creates ones–empty objects created in-line with the list. I ran the program and there it was; the GC was creating garbage again.
All this time, I always thought that that adding any class reference to a List would create garbage, but that’s not the case. As long as you add a reference form an object that will never be destroyed–say, one from an object pool–then no garbage will be created.
Project Shift Teaser
Posted in Uncategorized on July 18, 2011
Still no name, but it’s got a lot of game play.
Project Shift: After the Crash
Posted in Uncategorized on July 4, 2011
I decided it was time to make the first map. A lot of the game engine is functioning pretty well though the AI needs some work. I’ve already got most of the story laid out, but now it’s just a matter of creating all of the different models, textures, etc. I have to say that I’m very pleased with the Fbx Custom Processor. I don’t think I could ever have imagined creating a map like this one using Natur.
Check out the video; I would love some honest feedback.
Project Shift: Still Going Strong
Posted in Uncategorized on June 27, 2011
It’s late so I’m not going to write much, but I’ve been working hard on my current project. Here’s a little blurb on some of the things taking shape. I basically spent the weekend reshaping my engine a bit to accommodate a campaign type system. Still using Blender along with my Fbx Map processor to create everything.
Project Shift and a new Fbx Map Processor
Posted in Uncategorized on June 16, 2011
I’ve been working on a new custom content pipeline that reads maps, including bounding meshes and game logic, from an Fbx file. In the video below, I created the entire map using Blender.
Natur Source Now Available
Posted in Uncategorized on June 5, 2011
I was thinking about it, and since it’s going to be a while before I get back to Natur, I decided to upload the source. Visit Natur on Codeplex to check it out.
It’s not exactly the best version; I was working on the game engine side of it for a while, changing how the physics and animations worked, but none of that has been carried over yet. A lot of the new implementations are still lingering in Devious Knights. This is why I was so hesitant on releasing it early, but never-the-less have fun with it.
You can do some interesting things besides the obvious. For example, I had made a quick map one day using the Spawn system. Rather than using the spawns for spawning, I just used them as data holders for exporting and importing. You can also use the same type of data for different things by using the sectors. You can say Spawns in Sector 0 represent this, but Spawns in Sector 1 represent that, and so forth.
Height Maps with Paint.NET
Posted in Uncategorized on May 23, 2011
One of nice things about height maps is just how easy they are to create versus the effect they produce. You can create a height map from just about anything. All you need to do is desaturate your starting image; you may want to blur some of the harder edges to create more gradual terrain, but that’s all you really need to do.
If you take a look at the video in my recent post: Dynamic Water on the GPU, you can see how I created a height map by drawing text onto a gray scaled image.
Now that I’ve gotten somewhat comfortable with height maps, I’ve been working on a new game that will incorporate its use. This particular project is going to have pre-defined terrain so I’m going to need my height maps up front. To create the height maps, I’m using Paint.NET.
One of the nice features in Paint.NET is Render Clouds, located in Effects -> Render -> Clouds. Selecting this will render some clouds in the colors of your choosing; also, you can modify the clouds scale and roughness as well as reseed your current rendering until your satisfied.
The following is a basic height map created using Render Clouds:
This one could pass as a decent height map; however, if you take a look at how the terrain renders, it turns out to be a bit of a mess. The problem is that it’s got too much stuff going on. Bumpy hills are cool and all, but so are flat plains. Not everywhere needs to appear rugged.
You can try tweaking some of the different areas; smooth out some plains, sharpen up some mountain ranges, etc, but when I was trying to create a nice map, I thought back on some reading I had done regarding lighting. I had read an article about the 3-Light Setup; the idea is that you set three lights at particular angles create a range of shadow manipulation. For my height map, I wanted a range of terrain types from soft plains to hard mountain ranges; but I also wanted them blended together in order to maintain a natural look.
To apply the concept of the 3-Light Setup, I used Paint.NET’s layering ability to break my map up in such a way that each layer would offer the terrain I wanted. In a sense, I started off with my Fill Light; a layer that provided some subtle terrain differences from flat to small hills. I created this layer using the Render Cloud with a large scale but small amount of roughness. Then I smoothed it out by adjusting the brightness/contrast.
Next, I wanted some mountains. So I created another layer, and rendered a different set of clouds. I lessened the scale a bit in order to create more defined terrain (clouds), and slightly increased the roughness. I didn’t increase the roughness too much though; the mountains should appear more rugged, but since this will likely be walkable terrain, I don’t want the player bouncing all over the place.
I started off the last layer as a duplicate of the second. Similar to the back light, this layer helps define the mountains. After duplicating the layer, I increased its contrast and then balanced it by slightly increasing the brightness. Some of the areas are so subtle that I had to give it a pink background; the pink is technically black and represents zero height.
Lastly, I merge layer three onto two, and then onto one. The following is the resultant map. Again, I used pink to show you some of the subtle hills:
And to compare to how the basic map rendered, here’s how the layered map looks:
Dynamic Water on the GPU
Posted in XNA 4.0 on May 21, 2011
I have finally gotten my dynamic water running. The water is volumetric and processed entirely on the GPU. Now I can hopeful move forward with getting this little project a little more “gamey.”
Enjoy the video, and take a swim into XBLIG!





