How to add an isKeyDown() function
by Joe Spataro · in Torque Game Builder · 06/06/2005 (6:17 pm) · 4 replies
How would one add an isKeyDown() function and expose it to the script.
I searched through actionmap.h/cc and through the platform input stuff but I couldn't really figure out how it all worked.
What I would like to accomplish is to add this function with the intention of trying to use it in place of the bindCmd method of handling the movement of my player character in a beat-em-up game.
I searched through actionmap.h/cc and through the platform input stuff but I couldn't really figure out how it all worked.
What I would like to accomplish is to add this function with the intention of trying to use it in place of the bindCmd method of handling the movement of my player character in a beat-em-up game.
#2
first the key bind
then the commands it calls
then the isKeydown function
06/07/2005 (9:22 am)
What Philip said should accomplish exactly what you want... you could set it up like thisfirst the key bind
playerMap.bindCmd(keyboard, "a", "keyDown(\"a\");", "keyUp(\"a\");");
then the commands it calls
function keyDown(%key)
{
$keyDown[%key] = true;
}
function keyUp(%key)
{
$keyDown[%key] = false;
}then the isKeydown function
function isKeyDown(%key)
{
if(!$keyDown[%key])
return false;
return true;
}
#3
06/07/2005 (9:25 am)
Then to load a bunch of keys you can do thisfunction loadKeyBinds()
{
%keys = "a b c d e f g h i j k l m n o p";
%keyCount = getWordCount(%keys);
for(%i=0;%i<%keyCount;%i++)
{
%key = getWord(%keys, %i);
playerMap.bindCmd(keyboard, %key, "keyDown(\"" @ %key @ "\");", "keyUp(\"" @ %key "\");");
}
}
#4
06/07/2005 (9:41 am)
Wow. You guys are amazing. Thank you so very much!
Torque Owner Philip Mansfield
Default Studio Name
Not sure if that would actually achieve what you want though.