XNA Game Installers

This weekend, I’ve been thinking about ways to create an installer for my game project. For desktop applications, the technology of choice is of course Microsoft Windows Installer, which generates handy .msi files. It also automatically tracks which steps are neccessary to uninstall the application and it has the convenient repair function. However, when it comes to installing the .NET Framework, the DirectX Runtime or the XNA Framework, there seems to be no existing solution for integrating these steps into a single .msi package.

Another option would be to use NSIS, which requires you to write the uninstall actions yourself and also uses a rather cryptic scripting language, but otherwise provides all the features you expect from a modern installer. It even has LZMA compression (known from 7-Zip), which is far superior to the compression ratio of the .cab files embedded in .msi packages.

I couldn’t get my head wrapped around the declarative programming style used by WiX yet, so unless I discover a nice free MSI authoring toolkit that can be in automated builds, I’ll probably go with NSIS.

Well, whatever I’ll choose in the end, I’ve written a small DLL that can detect whether the .NET Framework (1.0/1.1/2.0/3.0) is installed, whether DirectX (9.0) is available, whether the XNA Framework (1.0/1.0 Refresh) is installed and whether the AGEIA PhysX System Software is in place. The DLL is written in pure C++ and doesn’t rely on anything, not even the C++ runtime libraries. It can be interfaced from both NSIS and MSI.

Screenshot of the NUnit GUI running some tests  detecting whether XNA framework is installed

If anyone wants to help create an installer template for XNA games, be welcome!

The Microsoft XNA logo, just the letter xna with the downward slash of the X colored orange

XNA vs Silverlight vs Native Code

If you write a game in Flash, you will have to accept some performance limitations and make some compromises in terms of available technology (eg. no Ageia PhysX or hardware shaders for you). But nearly everybody can play the game right in his browser, dramatically expanding the number of people that see your game.

Now Microsoft is hurling a competitor to Flash at the market: Microsoft Silverlight. It is based on the .NET Compact Framework 3.5 and WPF, which makes it about 1000 times more powerful than Flash. WPF also includes 3D graphics and is way faster than flash, allowing for full-screen animations where flash would slow down to a crawl. It’s being ported to Mono/Linux as well, with the help if none other than Microsoft!

Read More

XNA Vector Font Renderer

I’ve been fiddling around with font rendering again this weekend. For my upcoming game, I wanted a cool intro effect like in some movies, where the displayed text is very very slowly expanding. But I couldn’t quite replicate that effect with the XNA SpriteFont class. Even with antialiasing turned on, the borders of the text were flickering. Using very large font sizes resulted in hopelessly oversized .xnb files with only a slight improvement for the unsteady borders.

So my new solution was to write a component that renders vector-based text instead of bitmaps. Extracting the vector data from a font was a bit harder than I had expected because fonts consist mostly of complicated second and third order bezier curves. I managed to break these down into plain straight line segments and am now in the possession of a content pipeline importer that converts .ttf fonts into arrays of line segments. Behold:

Screenshot of vector fonts rendered as outlines in 3D

Read More

XNA Windows.Forms UserControl

Notice

This article is outdated!
This was a pretty cool achievement at the time, but XNA 1.0 is long gone. Microsoft now offers their own examples on how to do this:
WinForms Series 1: Graphics Device
WinForms Series 2: Content Loading

A topic that pops up every now and then is how to use XNA in a Windows.Forms application. This is rather difficult because the GraphicsDeviceManager provided by Microsoft creates its own window and will not cooperate with a normal Windows.Forms window, thus forcing the developer to roll his own GraphicsDevice initialization and management code (which is quite a bit of work!)

As can be seen in one of my recent news posts, I did just that while developing a world editor for my upcoming game Island War. Because of the great demand for such a component, I decided to release my XNA GameControl class to the public. You can download it here:

An XNA-based pong clone running inside a Windows.Forms application

How to use:

  1. Add a reference to Nuclex.GameControl.dll (or to the project if you integrated the project file into your solution)
  2. Create a new UserControl that inherits from Nuclex.GameControl. You can do this by adding a normal UserControl and replacing the : UserControl by : Nuclex.GameControl in the class definition.
  3. Override the LoadGraphicsContent(), UnloadGraphicsContent(), Update(), Draw() and so on methods as usual.

There’s one issue: Because the working directory will be set to the system’s temp folder when your control is shown in designer mode, you will not be able to view your game in the Visual Studio Forms Designer if it is loading content using the XNA content pipeline (well, unless you want to copy your project’s output folder into your temp directory whole). There will be no problems starting or debugging the project, though.

Island War Day 3

I decided to put some work into creating an editor that I can later use for building the levels and perhaps even include with my game. XNA gave me a hard time getting it to work inside a Windows.Forms application and I had to rewrite several of the XNA classes until I had a properly working XNA UserControl allowing me to render my game world inside the editor window.

Screenshot of a height map editor with dialog controls and a tool panel

Of course, the editor had to look modern and neat, with dockable panels and color gradients all over the place. As it turned out, there is no built-in solution for docking windows in the .NET Framework, so, given my plans to release the game’s source code, I had to find a solution that was both free and provided a decent user experience.

Read More

Island War Day 2

I know, as always, I’m a bit late with updates, but just in case you don’t know yet, the Microsoft guys finally opened www.xna.com. Finally, a complete website dedicated to XNA instead of the cramped MSDN section!

The developer area has been moved to http://creators.xna.com, including a wealth of tutorials and a revamped discussion area.

This weekend, I tried finally getting texture splatting to work for my Island War terrain renderer… and failed miserably :D. Look for yourself:

Screenshot of a height-mapped terrain with lighting and textures

There’s a lot of tuning to do until this crappy… something… looks like believable terrain. I’m not aiming for photorealism, but I’m not settling for a surreal landscape that stands out like a children’s painting would in an art gallery, either :)

Island War Day 1

Alright, my next game is finally on its way. The game’s working title will be “Island War”, which describes the setting of this game pretty well: small islands at war with each other.

And it won’t be like any other strategy title you might have played. I’m planning to remove the tediousness from the RTS genre by getting rid of micro management and unit placement.

I decided to try a different approach to the design of this game than I did with Ball Race. Instead of creating several GameComponents (like SceneGraph, EffectManager and GameStateManager) and spreading the game’s logic between them, I’ll try to model the game world in an object model designed for convenient use, so I can later set up my levels and launch the game with just a few lines of code.

Screenshot of a shaded height-mapped terrain without textures

The code so far incorporates an asset management system, the entire world expressed in an object model with load/save capability and can render dynamic height-mapped terrain allowing for real-time terrain deformation by explosions and other influences. I haven’t written the actual shaders yet, so this will look much better once I can get the shaders going.

CeGui#

If your game needs advanced GUI capabilities, CeGui# might just hit the nail on the head for you. Marketese aside, this is a seriously good GUI library with Buttons, ListBoxes, Scrollbars, ProgressBars, Sliders, ComboBoxes and more.

Screenshot of CEGUI# rendering its GUI into an XNA window

Being a port of the well known CeGui C++ library, it is not bound to a single graphics API but can instead be easily extended to run on a multitude of environments. Out of the box, it already provides extensions to be used with: XNA Framework 1.0, Managed DirectX 1.0, SDL.NET and Tao.OpenGL.

The only real problem for XNA developers might be that it does not yet work on the Xbox 360 due to several restrictions in the functionality of the .NET Compact Framework 2.0 that XNA applications have to build against on the Xbox 360.

Ball Race – Day 14

Today it dawned upon me that I forgot something important in the geometry generation engine of my game: How can the player distinguish the goals from the traps? Both are holes, only that the former one makes you win the game while the latter one makes you lose the game. Oops! :)

After today’s changes, the maze consisted of three parts: The walls, the floor (with donut gaps around holes that are goals) and the goal rings. The goal rings fill the gaps left open in the floor and use a different effect that draws a checkered flag texture so the player can clearly recognize the goal holes.

Screenshot of several maze boards with holes, one hole in each marked by a checkered ring

All that’s left now is to polish the game a bit, add gamepad support and create the 10 challenge mode levels. Looking back at the progress, I have to say that I underestimated the amount of work required quite a bit. It’s great to see some interest from the XNA community, some people have linked me in their blogs and I even got interviewed about my game and my thoughts on XNA. More on that if everything works out as expected.

The release of “Project Balance” will be on December 11th the same day the XNA final is due.

Ball Race – Day 13

Finally got a new graphics card. I had seriously considered buying a GeForce 8800, but given the card’s insane price tag, the fact that I’m developing for XNA (nothing to gain from DirectX 10) and ATI’s recent announcement about their next generation GPU being out soon to lower the prices, I decided to go for a cheap ATI Radeon X1950 card.

Photo of a PowerColor Radeon X1950 and its box

I didn’t totally stop working on the game, however, and wrote a small menu system that I now use to display the game’s main menu and the level selector. Debugging could still be accomplished running the game in a 320×240 window by using the reference rasterizer for rendering, which produces about 1 frame in the time it takes you to wash your car, take a walk or phone a friend…

Aforementioned menu system is already being used to drive the main menu and a level selector, both fully working at the time of this writing. The buttons themselfes are looking rather dull and I’m not sure yet whether I should just try to do my best in Paint.NET or whether I should go looking for an artist…

Screenshot of several maze game boards and buttons to select between them

There will be 10 built-in levels that the player can try to beat in a certain time to complete the game. I think 10 levels are just right to entertain the player for a while and then let him off before the game gets boring. I truly think it’s a nice and fun game, but, after all, it’s just a ball rolling around on a table — hardly enough variety to make 100 levels worthwhile :)