Advertisement

Control description language

Started by July 31, 2003 05:56 AM
1 comment, last by Robot Guy 21 years, 3 months ago
Hopefully somebody here can put me on the right track. I'm sort of working on a game (isn't everybody?) and I've come up with an idea to allow the used to select the control that they want in a highly flexible manner, but I need some advice. My plan is to have a sort of embedded language to convert events from the human interface devices (mouse, keyboard and joystick) into events to control the game (thrust level, fire weapon, turn rate, etc). I realised that doing this sort of set up "in game" is going to suck and that it would probably prevent me from using the same code in other programs, so I thought that having a seperate program that would allow ther user to configure the controls. This would create a sort of compiled bytecode that the game would load on start up. You could also allow the user to choose the file so that you can have more than one set up. What I really need is a description file that the game would export (and the configuration tool would import) that describes all the parameters that can be specified, with names, descriptions, types, limits, etc. I can quite easily create my own but I am sure that I have not only seen a standard for this sort of data but used it, but I can't remember what it was. Does anybody know of anything like this that I can use, because I'd rather use a standard than create my own (probably poor) imatation. I am loathed to ask this (because I should be able to find it myself) but I searched Google for ages without being able to find anything useful ... [edited by - Robot guy on July 31, 2003 6:57:28 AM]
Just a thought on how I would do such a thing...

I have not heard of any standard procedure for control configuration, although it is difficult to imagine that there is not one out there, as every game would use it. Otherwise, I would use a file in a scripting language to store the controls; here is a code fragment:


---------------------

-- controls.lua

...
key_fire = SPACE
key_left = LEFTARROW
key_right = RIGHTARROW
...

----------------------

//game.cpp

...
//in game loop
switch(event)
{
case(lua_getglobal(luaVM, key_fire)):
fire();
break;
...
}
...

-----------------------

I realise that this code is not entirely correct, nor is it the most efficient, but it''s just there to give you a few ideas. Good luck.
Advertisement
It's not actually the language I'm worried about as such, it's the description of the controls that the game has, something like :
<group name="Flight Controls">  <digital name="Fire">    <description>       This fires you weapon.    </description>  </digital>  <enumeration name="Weapon">    <value id="0">Machine gun</value>    <value id="1">Air to Air missile</value>    <value id="2">Air to Surface missile</value>    <description>       This selects the type of weapon you are using.    </description>  </enumeration>  <analogue name="Pitch>    <limits max="30" min="-30" \>    <description>       This pitches your craft up and down.    </description>  </analogue>     .     .     .  

(That's probably pretty close to what I'll end up with if I can't find a proper standard)

It's just I'm sure that I've seen something like this before as a standard (it might have been objects exporting values such as a thermostat exporting the temperature) and I would prefer to learn by other peoples mistakes.



[edited by - Robot guy on July 31, 2003 9:11:11 AM]

This topic is closed to new replies.

Advertisement