Suggestion:Add key and mouse release function

Posted By: ultranet

Suggestion:Add key and mouse release function - 06/28/07 04:38

I want to know why the scripting language doesn't add check key/mouse release functions?
Just like these things:
key_w_release, key_a_release, mouse_left_release, mouse_right_release......etc.
With these functions, scripting will be more handy, right?
Posted By: jcl

Re: Suggestion:Add key and mouse release function - 06/28/07 07:53

We don't want to implement trivial functions that can easily implemented by yourself. For this just evaluate the corresponding key or mouse values (mouse_left, mouse_right etc).
Posted By: ultranet

Re: Suggestion:Add key and mouse release function - 06/28/07 10:10

I don't think it is trivial functions...
Without checking release functions, I should write like this:

var key_w_release=off;
action PlayerAction()
{
while(1)
{
if(key_w && key_w_release==off)
{key_w_release=on;}
if(!key_w && key_w_release)
{
//other code
key_w_release=off;
}
wait(1);
}
}

I think this way is inconvenient.
with the release functions, I should only do this:
action PlayerAction()
{
while(1)
{
if(key_w_release)
{
//other code
}
wait(1);
}
}
Isn't this more concise?
Or just invent a general function to check if a key is released.
Such as check_key_release(key_w), return true or false.
Same as the mouse, check_mouse_release(mouse_left).
Posted By: Joey

Re: Suggestion:Add key and mouse release function - 06/28/07 15:08

you can of course implement a general function to check this. store all your keys you want to survive with their scancodes in an array (forget about the unused space this time, you could also use a dynamic list or something). then, per frame, work with key_pressed to store wether a key has been released this frame (you had the correct code in your last sample). write a small function which returns your release state. approximately 20 lines of code.

joey.
© 2024 lite-C Forums