Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There's nothing quite like the routine of tweaking a variable, compiling code that takes a few minutes, executing the code, realizing that your tweak was in the wrong direction and repeating the process all over again.

I would like to start interacting with my game logic while a session is in progress. What are some of the ways you've handled doing this?

I would be open to hear solutions for iOS, C/C++ and C#/XNA.

share|improve this question
up vote 12 down vote accepted

Just discovered this for iOS Developers -

You set up a server in your application and connect to it via terminal. You can then pump over remote commands and start manipulating variables in real-time. Pretty slick.

share|improve this answer

Integrating a fully interpreted language can allow you to rewrite game elements very, very easily on the fly.

Python, Lua, etc. can all be utilized expressly for this. Angel Engine probably can serve as an example.

Hot loading is another element to check out (basically, an event is fired off telling you an asset has changed--a config file, an art element, etc.--and you run it through a series of conditioners that modify it for the final format before replacing the existing with the new.

I've worked with a rapid prototyping engine that used hot loading and it was a pleasure.

share|improve this answer
Angel Engine looks interesting, thanks. – tenpn Jul 21 '10 at 18:51

Well as far as C++, C#, and C# with XNA are concerned, Visual Studio has excellent debugging tools--pause the application in real time at any point in the code, see the values assigned to variables at any time, step through function calls, analyze the call stack, and more. In addition, tools like Pix and the CLR Profiler make development with DirectX (Pix) and CLR based languages (CLR Profiler) great.

In addition, one especially useful part of working with games is that we have this giant area to write debug text, graphics, etc to. Realtime graphs of memory usage, number of objects/vertices drawn, framerate, etc are common things to draw to the screen.

share|improve this answer
While VS is an outstanding development tool, normal debugging takes time -- hunting down breakpoints, stepping through code, changing variables, restarting the flow. This question is looking for an immediate way to do things like move an interface component, or tweak a boss's attack ratio, etc. – David McGraw Jul 21 '10 at 17:41

In C/C++ a simple trick is to put your tweakable into a static variable, trigger a breakpoint, change the static in the debugger and it remains persistent until exit.

share|improve this answer
Make it a static variable inside a function though. If it's a global static Visual studio might not be able to show its value. – Kaj Sep 12 '10 at 17:52

HTTP Logging is a huge help, and not difficult to get up and running. You can even use Google App engine as a quick way of getting this running. Data is always useful.

Scripts & XML these can be reloaded on the fly and require no reset. Allow them to fail without bringing down the game. This gives a lot of power to artists, testers and designers.

In-Game Debug Menu A simple in game debug menu which you can spawn as a child and freeze the game with both engine sliders and game sliders. Allowing you to tweak key numbers at runtime and maybe perform one or two debug functions, or info dumps.

I also love ASYNC sockets as mentioned in David's answer

Easy to USE Your games team must be able to add to these tools and use them very easily, or they just won't get used.

share|improve this answer

I know Sean James already said it. But seriously, Visual Studio (specifically the debugging tools) is terrific for this.

I don't use C++ much these days, so I'm not sure about how well these apply there. But for C# (including in C# Express) you have:

  • Edit and Continue - where you can make wholesale changes to your game logic.
  • The Watch Window - where you can see and modify variables with ease.

And this might blow your mind (it blew mine when I found out about it):

The Immediate Window is actually kind of hard to find (it's in the Debug/Windows menu).

The only major downside to using the Visual C# debugger is that it doesn't like changing const values. So I usually just make my gameplay-related values static while I'm tweaking them.

(Also: having two monitors helps a lot.)

Now I must admit that the above method involves pausing your application - which can be unsatisfyingly slow for a few particularly fiddly things.

On these rare occasions, what I do (in XNA) is to simply hack in a bit of code (probably using Edit and Continue, as above) to grab Keyboard.GetState().IsKeyDown() (actually I have an easier-to-type wrapper for this) and adjust the value by keystrokes. Anything more complicated is not worth the effort.

In practice what I usually find vastly more important is being able to visualise (rather than modify) values in real-time. For this I have a nice little class that can buffer lines and text to be drawn at the end of the frame. It's also useful for quick prototyping.

(And, once again, it's nice to be able to "Edit and Continue" these visualisations in at runtime.)

(from here)

I'm afraid I don't have "nice" source to publish at the moment (maybe later). But it's basically just a list of lines (for this round line library) and strings (for XNA's built-in SpriteBatch). Just make it public static somewhere, and draw everything with an appropriate transform so that everything appears in "world space" (and then clear the lists for the next frame).

share|improve this answer

Writing a simple reflection system for C/C++ is fairly trivial. This way you can browse through all your variables in game (be it with a network tool, keyboard or joypad) and change them to your heart's content. It works for me, but all the above answers are equally valid.

Edited to add: This thread is now about tweaking, not debugging as per the thread-title.

share|improve this answer

One solution I've seen in multiple studios is an external debugging app that attaches to your program using the network. This app shows specific exposed variables, and allows you to edit them in real time. Adding new variables is a matter of adding some macros to the game code.

The initial set-up of the game-side macros, server/client protocol (the solutions I've seen just serialise xml back and forth), and writing the client, is large. However it's extremely useful, especially as using the network for communication means you can work on any platform.

share|improve this answer

Bind the loading and reading of the variable into a textfile and fire it up using a specific keybinding or command from console.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.