Random Thoughts
Programming Behaviour at a Very High Level
by ChrisH on Feb.05, 2010, under Random Thoughts
I’m currently finishing-off the C++ gameplay code for Orbyx and can’t help thinking it’s more difficult and messy than it should be. Internally I’m maintaining collections of entities, some with state-machines and most with event-driven behavior, and each of the event-handlers and interactions need to be hand-coded. This is not only slow but also leaves lots of room for bugs and potentially sloppy code.
Another option is to expose the interfaces of the entities to a scripting system, but this wouldn’t necessarily solve any problems for a small team. Maybe event handlers could be generated dynamically and bound to the scripted methods, and behaviour could be changed on-the-fly, but there would still be room for script bugs to creep in and these can be more difficult to track than native C++.
What would be really nice is a Very High Level point-and-click programming tool that would have access to the entity interface and state machine definitions, as well as the current scene graph data. Behaviour could be created in the tool in a natural language subject/predicate basis, and the underlying code would be generated automatically, very quickly, and bug-free. A simple example might be (where braces indicate drop-down combo boxes) :
IF ["gameplayControllerEntity"] [State] IS [Active]
- WHEN ["buttonPause"] [isClicked]
- - ["gameplayControllerEntity"] WILL [pauseGame]
- - AND
- - ["audioControllerEntity"] WILL [playMusic]
This can simply be thought of as:
IF [entity instance] [property] IS [value]
- WHEN [entity instance] [event]
- - [entity instance] WILL [method]
- - AND
- - [entity instance] WILL [method]
There are some issues that would need to be resolved, for instance how function paremeters are specified (clicking on the function name to edit params maybe?). I also think this tool needs to be 100% generic and data-driven, with entity interfaces and even basic data types specified in config files, and the initial scene graph in a Scene Definition file or database. Maybe entity interface definitions could be created from the game code as a visual studio build step, and we could even import resource file names by pointing at a directory. In theory there is no reason why a single line of hand-written code should be necessary.
Although this idea is certainly not new and there are likely to be lots of similar projects out there, I think I might be able to get it up & running with my game engine in it’s current state fairly quickly, and the benefits could be huge.


