Island War Day 7

Today, I’ve got some new screen shots! Read on :-)

Over the weekend, I implemented proper camera and terrain selection controls. Getting keyboard, mouse and gamepad working at the same time proved a bit of a nightmare. PC RTS players will expect the arrow keys to move around their view and the mouse to be usable as a selection tool. XBox 360 RTS players need some way of telling the game where to place buildings, but the gamepad isn’t suited for this task as well as the mouse is.

So I decided to split my terrain into a regular grid in which a terrain cursor can be moved. The grid is in units of 3×3 terrain quads, which allows me to add some detail to the terrain on the sub-grid-cell level. Otherwise, it would look fairly obvious to the player that the terrain is based on a heightmap with regular X/Y samples.

Screenshot of an island with flak buildings intercepting an incoming missile

Read More

Island War Day 6

During the past week, I got missiles working to a point where they will launch, gain altitude, head towards their target and dive for the attack. They will damage the island (which means scraping off texture layers and possibly alter the terrain, not sure whether I want this, however). Buildings in the vicinity are then destroyed.

For the missile trajectory, I went for the simplest thing that could possibly work:

  • Until the missile has reached its cruise altitude, it will ascend at a 45 degree angle. If during this phase, missile closes in to the target so much that it needs to start diving, the diving phase will be entered.

  • Once at its cruise altitude, the missile will simply fly in a horizontal line towards its target. If the missile gets closes enough to its target, it will enter the diving phase.

  • In the diving phase, the missile accelerates to maximum speed and descends towards its target at a 45 degree angle. Once it hits the ground, it explodes.

Read More
The logo of Microsoft's XNA platform, a framework for writing games in .NET

Why Beginners Should Start with XNA

Today, I watched an interesting discussion on gamedev.net where someone asked why everyone is recommending beginners to start off with XNA and C# whereas the entire gaming industry is based on C/C++.

I would have expected to read something along the lines of

“We recommend XNA because it’s very easy to learn and you will hit the ground running fast. It teaches beginners the kind of thinking required to lay out the logic of a program and doesn’t discourage them by forcing them to write boring console applications for months until they know the semantics of the language well enough to use a graphics library such as SDL, DirectX or OpenGL. Some people may not even want to enter the industry, so C# and XNA is a fine choice for them. Those that do can switch over to C/C++ after they’re fluent in C# and it will be a mostly easy going, incremental learning process.”

Instead, an ugly mess resulted with people firmly stating that .NET/Mono is the way to go for games, that the gaming industry is using it for prototyping, scripting and development tools and that the only reasons for not adopting C# yet are legacy code bases and unwillingness by developers to learn new stuff or to change proven ways. People began dissecting each other’s posts one by one and, well, if you’ve been on the internet some time, you can probably imagine how it turns out.

Read More

Island War Day 5

Last time, I wrote about how I set sail for the Island War project and how my motivation faltered slowly over time. And I promised to write a follow-up post that explains how I believe to get back on track and finish development of my Island War project. Well, here it is, folks!

I see the primary reason for my loss of motivation in my tendency to write and fully implement systems instead of just the piece of code I need. While I knew that I had to “write a game, not an engine”, I still fell for the same old trap: I didn’t technically write an engine, but I started to design entire systems and fully implement them when all I needed was a small routine to get the job done.

Read More

Island War Day 4

It’s baack!

Slowly, the Island War project begins to grind its wheels again. Time for a review of what’s happened so far. When I started this project, I was still intoxicated from the successful completion of my just-for-fun project “Ball Race”. I was eager to build a real, full-blown game taking no shortcuts and doing everything in the best way imaginable.

This turned out to be a real time waster and motivation sapper.

Read More
The logo of the WiX XNA intaller, a cheap montage of the WiX and XNA logos

WiX Installer for XNA Games

My GameSetupHelper library is making good progress. I was finally able to get some insight into the workings of WiX and Windows Installer.

I’m just about to create a small installer template for XNA games that will automatically check whether the required system components are available (for XNA games, these are DirectX 9.0c with the D3DX library from October 2006, the .NET Framework 2.0 and of course the XNA Framework).

Screenshot of a windows installer GUI showing the .NET/XNA/DirectX detection results

What I’m looking for now is feedback on the installer (you can find a download link for an example .msi at the end of this article).

  • Is the detection working for you?
  • Do you think the presentation is okay?
  • Do the logo bitmaps look abhorrent? (I’d happily accept any contributions *wink*)
  • Would people be scared by the additional slide during setup? (I tried to be honest about what the installer does to your system and at the same time follow MS recommendation to just silently install anything that’s required)
  • Do I violate any licenses with this? (I am including the official redistributables inside the MSI file, which to my understanding is legal)
  • Anything else that you think might be wrong or missing?

I plan to release the sources of this template for free once I’m done. If you absolutely need to get that installer sources NOW, just send me a mail :)

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.