Gw Temp

Menu

Article - 'The True Nature of .NET Programming' by Nate

An item about Game Design posted on Aug 8, 2003

Blurb

Nate, creator of LiveRPG, shares his thoughts on creating games and applications with Microsoft's new .NET technology.

Body

The True Nature of .NET Programming:
Believe the hype, ignore the lies



Hi folks, Nate here. In this article I’ll explain why Microsoft’s new .NET framework is a good choice for writing your own role-playing games, specifically why to choose languages such as Visual C#.net or Visual Basic.net over the more traditional approach of C++.



Before the age of Microsoft’s DirectX technology, games were programmed in DOS, and used technologies like VESA to get access to specialized features of video cards, such as higher resolutions and bit depths. These features were not natively supported by BIOS. DirectX came along and offered programmers a single interface for using virtually any hardware device uniformly. Since the release of DirectX, it, along with OpenGL, has become the premiere way to program games in Windows.



Aside from the purely technical and hardware aspects of programming games are the tools used to produce the game itself. C++ is currently the language of choice because it offers easy integration with COM-based DirectX, as well as C-based OpenGL. However, the evolution of Windows programming and DirectX has provided a new and exciting medium for programming games: .NET.



Microsoft has slated the next release of DirectX, version 9, to be packaged with a managed wrapper for use in Visual C#.net or Visual Basic.net applications. This means programmers can avoid the mess of dealing directly with COM in C++, and focus on the structure and flow of their games, while still enjoying the same speed of execution C++ programmers enjoy.



Role-playing games benefit much from .NET’s intelligent class design and integrated development environment (IDE). In my role-playing game maker, LiveRPG, I utilize a class hierarchy for game resources:



[Resource]

|____________[ImageResource]

|____________[MovieResource]

|____________[MusicResource]

|____________[SoundResource]



These classes, which exist in a class library external of LiveRPG, allow programmers writing .NET DLLs to subclass different resource types and create their own. You might call this a “plug-in” system. The same holds true for game objects, such as players, equipment, and items. With .NET, creating a class library such as the one I use takes a few seconds, and is as simple as defining the classes as you would with any other language. You don’t have to worry about entry-points, exports, or dependencies.



For instance, to create a class library that contains the Resource class, you’d simply create a new Class Library project, and add a code module containing your Resource class:



using System;



namespace LiveRPG.Resources

{

public abstract class Resource

{

public string resourceName;

public string resourceType;

public string dialogFilter;

public string fileExtensions;

}

}



Although this is an extremely simple example, using this class to create your own types of LiveRPG resources is as simple as adding a reference to the DLL from your project, and writing the class.



Since role-playing games are inherently object-based (a map contains objects, such as the player walking around on the map, monsters, items, etc.), using an object-oriented approach to programming your own role-playing game is a time-saving idea. C++ has these same concepts, but requires the programmer to have to worry about memory leaks, releasing COM interfaces, etc. With .NET, you simply code, and all the low-level stuff takes care of itself behind the scenes. It’s always a good thing when a programmer worries more about the design of his application than how much memory is being leaked.



Besides the utility of .NET in role-playing games, Microsoft still offers programmers the option of programming regular Win32 applications with Visual C++.net. However, you still have the option of using managed objects with Visual C++.net. Existing Visual C++ 6 or Visual Basic 6 projects can be imported and converted to .NET projects. The Visual C++.net compiler can still compile regular C++ applications. All these useful features make for a great development environment.



Additionally, the Visual Studio.net IDE is the most intuitive ever. It uses the new Office XP look and feel for all its toolbars, menus, and dockable windows. Language features such as Intellisense have been improved. You can even document your own code using XML comments in the code, and export the comments to an XML file to be distributed along with your module. Intellisense will detect the XML file and display the useful method and parameter information for people using your library.



.NET may be a new technology, but that doesn’t mean it’s a bad one. My recommendation is to obtain a copy of Visual Studio.net (academic edition will be available in mid-March, and will cost around $100) and see for yourself. Don’t take the recommendations of ignorant programmers who simply hate everything Microsoft stands for, and who claim .NET as some horrid beast. I’ve used programming environments from other companies such as Borland. Truly, Visual Studio.net offers the easiest way to develop Windows and Internet applications.



Happy coding!



Nathan Alden

Creator of LiveRPG (written in Visual C#.net)