Bork3D Games

Personal tools
From Bork3D
Jump to: navigation, search
The Bork3D Tweaker

The Tweaker

The Tweaker allows you to retrieve and set variables in your game at runtime. It works by enabling a web server in the game that displays variables you register with it. During the development of Anytime Golf I found the Tweaker to be surprisingly useful. I started by only using it to toggle rendering various debug information, but as development progressed I started moving more and more game state variables into the Tweaker. By the end of the development cycle I could drive the entire game through the Tweaker.


Using the Tweaker

The Tweaker is not enabled by default. (Having a web server running in the background would be bad)! To enable the Tweaker comment out NO_RUDETWEAKER in RudeTweaker.h:

//#define NO_RUDETWEAKER

To connect to the Tweaker while your game is running open a web browser and connect to port 8080 on the target system. For the simulator this is http://localhost:8080. Your iPhone will be different (get your iPhone's IP address from the network settings).

The Tweaker allows you to expose game variables to a web browser. Declare your variable somewhere as a global variable and then add a RUDE_TWEAK for it immediately following. For example, here's some tweaks I have defined for Anytime Golf:

// Toggle rendering the UI
bool gRenderUI = true;
RUDE_TWEAK(RenderUI, kBool, gRenderUI);
// Toggle the debug camera that lets you float around the world
bool gDebugCamera = false;
RUDE_TWEAK(DebugCamera, kBool, gDebugCamera);
// Modify material attributes at runtime.. this was AWESOME for tweaking the game's physics
RBTerrainMaterialInfo gMaterialInfos[kNumMaterialTypes] = {};
RUDE_TWEAK(MatRoughFriction, kFloat, gMaterialInfos[kRough].m_friction);
RUDE_TWEAK(MatRoughRestitution, kFloat, gMaterialInfos[kRough].m_restitution);
RUDE_TWEAK(MatRoughLinearDamping, kFloat, gMaterialInfos[kRough].m_linearDamping);
RUDE_TWEAK(MatRoughAngularDamping, kFloat, gMaterialInfos[kRough].m_angularDamping);
RUDE_TWEAK(MatRoughMinVelocity, kFloat, gMaterialInfos[kRough].m_minVelocity);