Varcade Dev Blog

Author Archive

Explosions and Waves

by on Mar.05, 2010, under Games

Looking around the XNA site and still learning a lot, I found I nice example of smoke and explosions in the Particles Example. This was fairly simple to get in the game, and shows how to use a DrawableGameComponent, and also my first look at how an inherited class can call a specific constructor of it’s base. This guide on C# constructors was helpful.

I’ve created  the concept of a Enemy Wave, a group of enemies to be deployed. I made a couple more placeholder enemies graphics an gave each type is own class inherited from gameObject. making them easy to create and manage.  I put a ‘startbox’ at the beginning of the path, and check if its empty of enemies ( meaning the last deployed enemy has got out of the way), and deploy more if it is.

The white circle is the cursor, but I’m calling it the Picker.  It moves with the left thumbstick, and you can accelerate its movement my using the left trigger. It’s working pretty well in place of a mouse.  I’ve created a color map to determine if the picker is over certain areas.

The code for that looks like:

currentLevel.backgroundMask.GetDat(0, selectRect, pixelData, 0, pixelData.Count());

     foreach (Color color in pixelData)
         // test is everything in White
         if (color != Color.White)

            isSelectable = false;

Leave a Comment more...

Smoke on the ground

by on Mar.04, 2010, under Games

I was able to expand the pathing a bit, now enemies can have a path offset when they are deployed, this lets multiple enemies travel in a sort of formation. It is still primitive but works. In the screenshot below, the white dots are the defined path, the colored ones are the ones the enemies are using.

It took a while to figure how to create an offset path, having done something similar in 3D in the past, I was pretty sure I would need the cross-product or some fancy math to find my new point,  the solution turned out to be incredibly simple:

public static Vector2 Perpendicular(Vector2 a)
return new Vector2(a.Y * -1, a.X);

Ya, I  havn’t really tried to understand how it works, it just does.

I also created a smokeObject class, to make dust clouds as gameObjects move across the ground.  This turned out pretty nice, after a good bit of trail-and-error, I got the smoke to get pushed along with the object like a wake on a boat, then fall off, and get pulled away with the wind.

Leave a Comment more...

3D to 2.5D with Sprite Sheets

by on Mar.02, 2010, under Games

Having gone thru the 2D Turorial, I learned how to load, draw, move, and rotate a sprite using the XNA framework.  Then I had a look at some sprite sheet tutorials, such as Sprite Sheets in Xna: The Basics

Now I wanted to get my own graphics in play, and simulate some 2.5D.  Specifically, a 3D rendered object that would show a different angle depending on the direction it is moving, roughly like so:

moving left: moving up: moving right: moving down: 

Now if we were doing a straight top down view, we could use a single overhead image in our sprite, and just rotate it in XNA.  But since we are showing a little bit of perspective ( note how you can see the near side of the tank slightly in the left and right views ), we will need some pre-rendered images of all ( or most ) of the possible angles the object can be seen at.

I grabbed a free model from TurboSquid.

I found several scripts for 3D Studio, that would help automate the process:

Sprite Render Script – did not try this one yet, but looks good
Sprite Render Tool – used this one, it’s old and had a bug I had to fix when doing more then the default 8 views

Other utilities used to finish the process:

Smart Cropper V2 – batch image cropper that finds the smallest size across multiple images
GlueIt 1.06 – joins multiple bitmaps into a single sprite sheet

Here is what my first attempt resulted in (rough version with bad shadows):


I was able to render these to PNG format so the transparency mask was built in, and worked perfectly to blend them to the background in XNA.  I created a new class for my game objects, that would automatically display the correct panel based on the object’s current direction of movement. And then I tweaked it one step further, that if the rotation in the image wasn’t an exact match to what was happening in game, it would compenstate by adding a a slight amount of rotation to the sprite as well.  After a bit of tweaking, this came out very nice.

3 Comments more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!


A few highly recommended websites...