|
Keyboard |
vinze80
Member #7,072
March 2006
|
Hi, This is a short passage of how I manage the keyboard. int touche; while (valid==0) { if(keypressed()) { touche=readkey(); if(touche>>8 == KEY_UP) {.... } } }
|
kazzmir
Member #1,786
December 2001
|
It has something to do with the repeat sensitivity of the keyboard. I forget how to change that, maybe you can look it up, but heres some code that might work better in the long run. while ( valid == 0 ){ if ( key[ KEY_UP ] ){ ... } } The key[] array is automatically updated by allegro via interrupts so you dont need any other special code to detect when the keyboard is pressed. |
vinze80
Member #7,072
March 2006
|
I try as you said me. but it is always the same. one foot, one stop and go on continue. |
kazzmir
Member #1,786
December 2001
|
Can you paste the rest of the code that you use to move your circle? |
vinze80
Member #7,072
March 2006
|
This is my code. |
Michael Faerber
Member #4,800
July 2004
|
Using readkey() and keypressed() will have that effect. You need to replace readkey() and keypressed() with key[]. [EDIT]
-- |
kazzmir
Member #1,786
December 2001
|
Vinze, can you paste your code using the key[] array so we can be sure you are using it correctly? Michael, no offense but thats almost exactly what I wrote above anyway :p. |
vinze80
Member #7,072
March 2006
|
I tried with "key[KEY_UP]" exactly the same as Michael has written. |
Michael Faerber
Member #4,800
July 2004
|
Quote: Michael, no offense but thats almost exactly what I wrote above anyway :p. Yes, but I thought he didn't get it, because he said that it was still the same behaviour. Quote:
But with that, I lose completely the control of my keys. You have to divide your program into logic and draw parts. See this and search the forums. -- |
vinze80
Member #7,072
March 2006
|
Tanks for the link, I searched how can I use timer with allegro. |
vixinu
Member #7,343
June 2006
|
for Michael's code Michael Faerber said: It probably should be
|
Lucid Nightmare
Member #5,982
July 2005
|
check this out... its from the allegro keyboard routines- http://shamis.0nyx.com/download.html or http://shamis.0nyx.com/zips/kr.zip Two Golden Rules of life- Firstly, I'm always right and secondly, if you think otherwise, slap your face and read rule number one again! |
|