Advertisement

how to make it so when a button is pushed it does not repeat command

Started by March 10, 2002 05:41 AM
5 comments, last by ShCiPwA 22 years, 11 months ago
in my program when you push a button it passes the first if statement and if it is held it keeps passing on every frame... How do i make it so when it is pushed once you have to let go to make it pass again? Know what i mean?? Thanx, ShCiPwA ----- ShCiPwA -----
----- ShCiPwA -----
you need something like :
bool keyClick( char x );

you need 2 variables for each key.
one for state of key in this frame and one in las one. than just ask if key is pressed in this frame and not in last one than execute your procedure. at the end of frame copy value of key at this frame to key at last frame...


There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.
Advertisement
Thanx, I sorta get you

You mean like:

if(keys1[D] && !last_keys[D])
{
Punch...
}

Gotcha

----- ShCiPwA -----
----- ShCiPwA -----
One more thing...

How would i transfer keys1 into last_keys?

Is there an easyer way than:

for(int i; i <256 ;i++)
{
last_keys = keys<br>} </i> <br><br>—– ShCiPwA —–
----- ShCiPwA -----
you can use memcpy( last_keys, keys, 256 ); or something like that..

There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.
why not tring:

lastKey[D] = keys1[D];

Advertisement
glnefugio: that''s great! you just have to write it down 256 times (or for all keys you use) ...joke!
anyways.. dont bother optimizih this since you''re doing it once per frame and time saved on this is minimum....

There are more worlds than the one that you hold in your hand...
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement