Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Christopher Bennage

Our WPF book is now available!


Game Programming with .NET 3.0

Introduction 

Rob Eisenberg and I are writing a game in .NET 3.0. We entered the game into Microsoft Code Master Challenge and we made the semi-finals.  Today we had to make a 20 minute online presentation to a panel of judges using Microsoft's new Live Meeting, and while the presentation did not go as well as we would like, we are very excited about the game itself.

 Back in the early 90's, I used to haunt the BBS's on my 9600 baud modem (or was it 2400?) and my first exposure to online multiplayer gaming was something called Trade Wars.  It left quite a mark, and I always wanted to write my own version of the game.  About three years ago, I discovered a number of servers hosting the game (you can connect with telnet) and within two weeks I had half a dozen friends playing.  (Rob even set aside Knights of the Old Republic to play!)  This motivated me again to consider writing my own spiritual successor to the game.

We started out with .NET 1.1 and the intention to use Flash for the client. (I did a prototype using Flash Remoting to pull a star map from SQL Server and render it in 3D).   Aftersome initial design work,  and a little bit of coding, Work got in the way for two years.  As we began to learn about WinFX, the fire began to kindle, and when the Code Master challenge came along the time was ripe.  We gave the game the codename Empyrean.

So why .NET 3.0? 

I mean, aside from the fact that we are both .NET developers (and XNA wasn't available when we started).

The Windwos Presentation Foundation was a natural fit for the type of client I wanted.  I wanted the features Flash had to offer, vector-based graphics, timelines (storyboards), etc. and WPF has them (and 3D support!).  The only negative was that the potential audience would not be as large.  I decided that I could live with that. 

Rob and I have both been interested in Interactive Story Telling and we wanted the world of Empyrean to feel alive and moving.  We wanted the NPC's to be interesting, dynamic, and adaptive.  It did not take long to realize that Windows Workflow Foundation could provide a lot of the infrasture to support our ideas.  Early on, we had a notion of "workflow based" AI's and eventually "workflow based" quests.

Windows Communications Foundation made sense because, well, it's a multilplayer game and WCF greatly simplifies the networking API.

Funny enough, Kevin Hoffman was having similiar ideas, and he's currently working on a .NET 3.0 Trade Wars inspired game called Ulysses Agenda

Features Of The Game

Empyrean Screenshot

That is: features as they relate to .NET 3.0.  This is a developer's blog! 

In the game, you fly around in a starship and you can purchase new  starships when you save up the money.  We wanted the game's UI to reflect the ship you currently own.  We did this by creating a series of controls that support templating.  The controls do things like displaying your character's stats, or exposing game commands (trade, attack, scan).  We then create a set of themed templates in WPF's markup language, XAML, and store that XAML in a database, then we deliver the XAML to client whenever they purchase a new starship. (Of course, right now we only have two skins.)

As mentioned above, the NPC's use WF to make decisions.   NPC's have certain types of behaviors (trading behavior, combat behavior, etc.) and for each of these behaviors we designate a WF workflow.  The markup is stored in the database.  This allows us to tweak the behavior of NPC's ad nauseam.  So when a player approaches an NPC, hoping to purchase something, the NPC loads a workflow to decide what to charge for the item (or to if they kick the player out of the store, or attack the player, or whatever!)

The other visual conent of the game (portraits of NPC's, models of starships and space stations) is all also stored in the database as XAML.  We used eRain's ZAM 3D and Blender (with Daniel Lehenbauer's export script) to produce the 3D content.  Fireworks (with Infragistics' XAML Exporter) was the primary tool for 2D content (I haven't gotten my head around Expression Graphics Designer yet).

All of this (skinning, visuals, workflows) allows each server running the game to vary widely.  An administrator of the game could configure the game to look and behave however they want.

We use WCF to expose an RSS feed with player specific information (such as what has happened to you in between game sessions) and a Vista gadget that displays the feed.

Question for You

Is this interesting to anyone out there?  Would you like me to blog more about our game development efforts?  Things like implementing the A* alogrithm in C#.

Or would you prefer for me to keep in in the realm of Business Development?  (Our game development is still heavily patterns influenced and domain driven; we also wrote our own OR\M that the game uses). 

I will post more about .NET 3.0 and what I have learned in that respect.


 



Comments

Billy McCafferty said:

Nice post!  Keep the game development blogs coming!  I've written Frogger in C++ and a rip-off of the side-scroller Kid Icarus (http://en.wikipedia.org/wiki/Kid_Icarus).  I also have a stack of game development books at home gathering dust since the day I realized that I'd need trade my family in if I really wanted to pursue game development.

Also, if you're looking for suggestions, Microsoft's Terrarium (www.windowsforms.net/Terrarium)  makes a perfect platform for teaching people about A* and the like without a lot of overhead.  With Terrarium, you can focus on the game logic without worrying about creating a gaming platform.

# November 9, 2006 6:52 PM

John said:

We want more game posts! There's enough business development blogs out there. We need somthing new and exciting. I think this is just right! Great post.

# November 9, 2006 10:20 PM

Marlun said:

Yeah, I would like some more game posts as well :)

# November 10, 2006 2:33 AM

Bg_ said:

If you want a good implementation of A* in C#, you may take a look at http://www.codeproject.com/useritems/PathFinder.asp

Hope this help will help you and good luck :)

# November 10, 2006 3:57 AM

Eber Irigoyen said:

game development is always interesting, I'm looking forward to see some blog posts about your experiences, I'm trying to get into XNA and that stuff my self

# November 10, 2006 6:57 PM

Peter said:

I think this is a great way to showcase the power of the .NET 3.0 features.  I'm really interested in Workflow Foundation but all of the examples are "send this form to your manager for approval . . . route it to HR for scheduling purposes . . . then you blah blah [yawn] blah blah blah."  This was a great eye-opener!

# November 14, 2006 1:13 PM

Scott Criswell said:

Hey Christopher,

I LOVE the improvements in the UI that you've made since the first drafts. Awesome work guys!

# November 14, 2006 3:15 PM

.NET & Funky Fresh said:

First I'd like to say that I'm stoked about the work the Prism team has been doing.  I have

# June 6, 2008 9:24 AM

About Christopher Bennage

Christopher is a software developer and consultant at Blue Spire Consulting, a company he co-founded with Rob Eisenberg in 2006. He is a Christian, a marginal musician, and an armchair philosopher. His interests include programming, liberal education, science, truth, beauty, and a number of deceased British authors (C. S. Lewis, G. K. Chesterton, and most recently Owen Barfield.) He lives in Tallahassee, FL with his wife and three children and still prefers to play as the Night Elves in WarCraft 3. Check out Devlicio.us!

Our Sponsors

Red-Gate!