Drawing Lines in XNA

One of the things I realized is very handy when prototyping or debugging is to draw a line on a specific location. Like drawing lines around collision boxes to see if your character is making a proper collision. For my games I’ve made a small LineBatch. Basically LineBatch uses a SpriteBatch to draw the lines by stretching a 1×1 white Texture2D to your line size. You can give it 2 points ( start and end point of course) and a color. There’s an overload function that receives the Layer parameter. ...

January 26, 2010 · 1 min · 163 words · David Amador

Xna Screen Manager

I know there’s lot’s of this stuff over the internet but I keep bumping into people asking for this. A way to easily switch from a Game Screen to a Menu or Options without having tons of flags and “if” clauses on the class Game. I’ve made a small project with a Screen Manager. The ScreenManager is static and can contain Screens. Instead of having typical Draw Update functions drawing SpriteBatches on the Game class we should have something like this: ...

January 24, 2010 · 2 min · 314 words · David Amador

Basalt and Sapphire Updates

Lately all my free time has been spent adding new features to Basalt and developing Sapphire. Some months ago, I started building Sapphire, a 2D editor for helping me creating to create my maps. Unfortunately I made a bad choice and decided to integrate XNA with Windows Forms, although I managed to do it it was a real pain to add something simple and eventually I dropped it. Here’s a screenshot of the previous alpha version: ...

December 2, 2009 · 2 min · 245 words · David Amador

How to do a XNA fps counter

Frame rate or FPS, how it is most commonly known is a way for you to know how many images per second is you game drawing. The more the better. Less then 30 and you start to see hiccups. So how can you measure your frame rate in XNA? Inside your game1 class declare these vars: SpriteFont _spr_font; int _total_frames = 0; float _elapsed_time = 0.0f; int _fps = 0; On function LoadContent() do // Put the name of the font _spr_font = Content.Load("kootenay"); you have on your project On the update pump do: ...

November 23, 2009 · 2 min · 254 words · David Amador

Using PerfHUD with XNA

I am definitely a fan of ATI cards. Had a few Geforces but didn’t liked them very much. I actually noticed image quality decrease when switching from an old Radeon 9800 to a Geforce 8k something. I’m very happy with my Radeon 4890, now for the downside, PerfHUD, a very handy tool for Game Developers is only available for NVIDIA chipsets and although ATI has it’s own GPUPerfStudio it’s not the same thing. Anyway for those who have one and are developing for XNA you may have noticed that it doesn’t run PerfHUD out of the box. You will get an error, something like: “This applications is not configured for using PerfHUD. Consult the User’s Guide for more information” ...

November 18, 2009 · 2 min · 293 words · David Amador

Prototype for xna7day competition

I decided to make a game for the xna7day competition, in which we have to make a game that only uses 2 keys, so absolutely no analog input and it has to be built on xna of course. This is a great opportunity to test my engine Basalt. I decided to make a puzzle game, basically the rules are the same of a 3 in line game. This is what I have so far. ...

October 29, 2009 · 1 min · 74 words · David Amador

Building an 2D Game Engine in XNA - Part 1

I decided to starting writing a series of tutorials for building an 2d XNA game engine. Keep in mind that while the main focus is 2d nothing prevents us from adding the 3d stuff later but for now we will stick to 2D. It’s not very original but I’ll call this the Bay Engine. If anyone else has a better idea let me know. Requirements: You must have some Object Oriented Programming background to full understand what we will do here. XNA 3.1 Visual C# Express or Professional 2008 This is it for the first part. It just covers the basic structure, next week I’ll talk about objects2d, scene and screens management. ...

October 16, 2009 · 1 min · 112 words · David Amador

XNA Camera 2d with zoom and rotation

07/01/2011 – By popular request updated to XNA 4.0, xna 3.1 code is still there too One of the things I keep finding is people asking how to do a simple camera 2d in XNA. Today I decided to contribute with my own solution. Most of the time the solution given is to have a class camera with a Vector2 position and when drawing the sprite batch to subtract the camera position to the sprite position itself. Although this work from my point of view it’s not elegant and you can’t have neat features like zooming and rotation. So for my tutorial I’ll do all transformations using a Matrix. Start off by creating the basic class Camera2d ...

October 12, 2009 · 3 min · 433 words · David Amador

Basalt gains a media player

So I’ve been working on a sort of media player in order to play movies on my 2d engine Basalt made on top of XNA. By extending my class Object2d I manage to get this pretty cool result. You can even apply shaders to it. Since I extended the class from Object2d I can rotate, scale and set a position to the video besides regular options like play/pause, fullscreen etc. For those who don’t know the video playing is a chunk of the series Naruto Shippuuden ...

October 4, 2009 · 1 min · 86 words · David Amador

XNA Sprite Sheet

I decided to take the morning to make a small sprite sheet editor for our Xna engine. This way the artist can easily define the sprite areas and their origin saving in a file that can later on be loaded on the engine. Not very fancy yet but it gets the job done. Next step will be making an animator editor.

August 23, 2009 · 1 min · 61 words · David Amador