XNA Editor – Stepping Back to Design

February 3, 2010

As the design behind my game changed over time,  becoming more complex (feature creep == bad, but that’s another topic)  I began to realize my editor was falling behind my game. I didn’t want to limit my game by using mediocre tools that took a long time to make, and were difficult to maintain, so I decided to go back to the drawing board.

First this meant rethinking what an editor should do, why it should do those things, and how it will do them.

Why have an editor?

This is the first question any developer should ask themselves before plunging into writing code. Why am I writing this, why do I need it? Sometimes asking this question leads to the realization that you don’t actually need to write anything, because the idea is unnecessary. If your game is small enough that you can create the amount of content you want using some other tool faster than writing an editor, you don’t need an editor. Similarly, if your game is simple enough that an editor doesn’t help you make better assets, you don’t need an editor.

Another reason to have an editor, is the ability to use the same editor to create assets for multiple games. In the long run, the time required to make an editor can pay off if you use it enough. If this sounds like you, there are some key things to keep in mind when you’re building your editor. Which we’ll discuss momentarily.

What should an editor do (and what shouldn’t it do!)

Once you’ve decided you need an editor, you need to think about what kind of things it should do. Since I want my editor to be reusable for many games, I have to be vary careful to think of it as a distinct project, separate from actual game project. It can be a huge pain to finish something, and try to use it on another project only to find out that the editor won’t work without a ton of game specific features and code.

In a simple outline I decided that my editor should allow users to:

  • Create in-game objects (Potentially from a library of pre-created objects, or the ability to create new objects)
  • Move/Rotate these objects
  • Create very specific objects that are game dependent (Just because we want the editor to be distinct from the game, we don’t want to gimp the editor, thus limiting how unique and vibrant our game will be. This means we need a very dynamic and modular way of handling these types of objects)
  • Undo/Redo support. (I had an old editor without these features, because they didn’t seem worth the trouble of implementing compared to features that would directly effect the game. Boy was I wrong! It was a time consuming mess, and try getting someone who isn’t a programmer to use it..)
  • Export/Import the scene to some format that is readable by the game and the editor.

This was the basic feature-set I decided my editor should have. Notice that none of these things specifically mentions anything unique to any game.  Its all very generic, and thus will be reusable.

How should an editor do these things?

This for me at least, brought on a question I still don’t know if I have the correct answer to.

At first, as you can see in some of my older posts, I thought the answer was simple:

“I will create a beautiful WinForms application with all the bells and whistles any good commercial editor would contain! It’ll be easy to use because it’s just like any program we’re used to using on a computer, and it will be powerful enough that we can do lots of amazing things with it.”

The editor, actually succeeded on a lot of those things, but the more I used it to actually design scenes for my game, the more I felt that I had gone about it the wrong way. It felt too separated from the game, it was difficult to gauge how the scene would actually play out once I loaded it into the engine. Sure I had a feature where it would launch whatever game I was working on and create the scene just like it looked in the editor, but it just felt clunky somehow.

I decided to try a little experiment.

WinForms vs. GameComponent

Maybe WinForms wasn’t the way to go about this. To me it wasn’t even a question when I first started, even though it should have been. It seems like most people in the XNA community, myself included,  just assume that is the best way to go. After all, that’s how the professionals work! Right?

Compare the number of topics asking about how to get things working with WinForms to the number of topics about in-game editors on the XNA Forums and you’ll see what I mean.

So far I can say that implementing the editor through a GameComponent type of system has huge benefits over the WinForms way of doing things. Combined with my console component, all I have to do is type “editor” in my console and I instantly have a fully featured editor overlayed on top of my game. I can do all of the things I outlined above, and instantly switch back to playing my game, and try out my changes. This allows me to make much more informed design choices, which results in levels that are much more fun and challenging.

To anyone who has tried to use XNA in a WinForm setting, it’s clear that it is possible to do it this way (and getting better with each new realize of the XNA Framework) it doesn’t feel like it was designed to do it this way. Gone are the familiar Update and Draw loops. Gone is the ‘Game’ class which makes using many great components/features/services difficult or impossible to use. The ability to use all of the XNA Framework to create the editor without ugly hacks to get things working with WinForms made development much quicker.

Another potentially huge reason to use this type of design is that the editor can be included with games for release. That means adding potentially limitless replay value. Combine that with online sharing of levels (even over Xbox LIVE!) and it could be a recipe for a more successful game.
I’ll end this post with a summary of  my opinions on the GameComponent way of doing things:

Pros:

  • Instant design feedback
  • Access to familiar design paradigm (Update/Draw/Components/Game/etc)
  • Xbox 360 compatible
  • No need to use obscure hacks and bad code to get things refreshing properly
  • Edit with full animation at 60fps with no extra work, you can do whatever your game can do. (Great for editing particle effects, etc)
  • More user friendly (if done well)
  • Don’t have to re-implement some WinForm compatible versions of code that already works in your game
  • Have access to any parts of the XNA Framework that you have access to when making a game.

Cons:

  • Have to create some things that already exist as part of the WinForms library (E.g. PropertyBox, TextBoxes, ListsBoxes, other UI stuff)
  • If you do decide to ship the editor with your game, it needs to bug/crash free.
  • It goes against your desire to have a pretty Windows application!

I’d love to hear comments on how other people have done editors, or their thoughts on which way of doing this is better.

Also, would anyone be interested in seeing how I structured the system for my editor? If so, would you like to see code samples, tutorials or some other format?


AntiForce Editor Update!

July 17, 2009

Hi!

I’ve been working on the AntiForce editor some more (more than I should be, I need to spend more time on the game itself) and I made a little YouTube video to show it off.

I’ve actually made a few changes to it since I made the video. Namely the ability to import graphics files and use them in levels, and the ability to test levels with 2 mouse clicks. It’s pretty awesome. Making scenes should be super smooth. C# and XNA rock!

If you want to watch it in glorious HD, you should head over to YouTube to watch it.


Avatar Fun!

June 15, 2009

So now that XNA 3.1 is out, I’ve been playing around with Avatar’s for a bit (don’t worry, I’m still working on ElectroStatic too). So far I don’t have a lot, but this is just a little screenshot of a stupid demo I made where you can spawn a random avatar on some terrain by pulling the left trigger. Its somehow quite creepy.

More to come once I have something real!

Silly Avatar App to test some functions

Silly Avatar App to test some functions


XNA 3.1 Released

June 11, 2009

Well, XNA 3.1 is finally here!

After a slight delay from the original goal of ‘May’ XNA 3.1 finally shipped today with a slew of new features including:

  • Avatar Support: Developers now have access to Gamer’s avatars for use in game. There are also functions for randomly generating and using custom shaders. I’m sure we’ll see a lot of  ‘Avatar Games’ where they’ll be nothing but gimmicky generic games, but hopefully we’ll get to see a few good titles as well (Maybe even by us once ElectroStatic is finished.
  • Video Support: We have the ability to include video files in XNA games. Major issues here are the requirements of video being in Microsoft’s ‘.wmv’ format, and the filesize this will add to games. Most 200 point games probably won’t include video. Not really sure how useful this is, but quite fun to play around with.
  • Xbox Live Party: The same Party system that allows users to communicate with players outside of your game. This may help to boost sales of XNA games, but we’ll have to see. To be honest, my friends and I rarely use this feature. I’m not sure if other people use it more. Either way, I’ll be including support for it in all of Anti-Force’s titles. And so should other developers! Polish, polish, polish!
  • Content Pipeline: Serialization and Deserialization will be much more streamlined now. We won’t have to (unless we want to) write ContentTypeProcessors and ContentTypeWriters anymore. Using reflection, it will all be done behind the scene. This is great because there is nothing I hate more than writing content related code. The only real downside here is that reflection is slow, and if you have long loading times, you may want to go back and write them manually to squeeze out a little more speed.
  • XACT3: Since the Audio API came out for XNA, I haven’t used XACT much, but we get access to the new version now, which has a few nice features including filters on every track, and xWMA compression. I’ll be checking this out in the future.
  • Audio API Update: The audio API released with XNA 3.0 was far from perfect. It still isn’t I’m sure, but its looking to be a lot better, with some nice changes.

Overall a nice set of upgrades to an already great framework. I think of all the new features the Content Pipeline stuff is probably my favorite, although playing around with Avatar’s will be fun, I’m not sure it will be a lasting joy. Plus I have a cloud of dread in my mind about all the crappy Avatar games that will be released…

Finally, Xbox LIVE Community Games has officially been renamed to Xbox LIVE Indie Games. While this is a superficial change, I do like it. I think it better represents what the channel is. Hopefully it will ignite more interest and result in more purchases of XNA games.

You can see a huge list of all the nitty-gritty details here. What’s your favorite new feature?


Some New Screenshots!

May 26, 2009

Hello again!

It feels like it was forever ago that we posted the first video, and we’ve certainly come a long ways since then. Some of it can’t really be shown in screenshot form, so hopefully we’ll have a new video by the end of the week, possibly along with the first developer podcast.

Anyways, here are a few screenshots to show you what has been done since the video.

Character Re-design and background as requested!

Character Re-design and background as requested!


Award System (Like Achievements)

Award System (Like Achievements)


SS4


Anti-Force Editor

May 23, 2009

So I’ve spent a lot of time recently working on a game editor that is quite proffessional looking, and quite user friendly. My hopes are that this will result in a better quality game, because the levels will be easier to make.
One of the most important features I considered when making the level editor was extreme extendablility. I wanted to code the editor once, and using my engine, have it work for any game I make, even if I include more complex game-specific objects. The solution I came up with is quite simple, and works extremely well.

editor1

Main Editor Screen

When you start the editor, you can ‘attach’ the editor to a .exe or .dll (I’m considering allowing the editor to attach to multiple assemblies), and it scans the assemblies for classes that use the [KLib.Editor.EditorObject] attribute. It simply adds all of these classes to a list, where you can create them in the editor. Each object that has the EditorObject attribute controls how it is created in the editor. This allows for unique custom objects, without changing any code in the editor at all.

Not only that, but I handle serialization in the same way. During the serialization process, objects that impliment the ICustomSceneLoading interface specify object-specific serialization, which allows the editor to save custom information to objects that require it.
The result is a modular editor that is simple, extendable and efficient.
Here are a few screenshots of the editor (I may post a video within a few days), if anyone is interesting in seeing code samples or even a tutorial of how I did this, please leave a comment!

Asset Manager

Asset Manager

TileGrid Editor

TileGrid Editor

Main Editor After (Notice Layers)

Main Editor After (Notice Layers)


Recording the first Podcast tonight!

May 22, 2009

So Jason, Greg and I will be recording our first Developer Podcast for ElectroStatic. Hopefully it will turn out well.
I’ll post a link tomorrow hopefully.

Don’t forget to follow me on Twitter for those of you who are interested!


Welcome to the Anti-Force Blog!

May 20, 2009

We decided to start a blog to show updates to our XNA Game, ElectroStatic. We have this old YouTube video from a while back, but we’re going to update really soon with more updates! For now, watch the vid:

We’re going to start a weekly podcast, possibly starting this friday, so check it out =D