![]() |
#1 | ||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Dec 2004
Location: ,
Posts: 50
|
![]() Okay, I have a few SDL sprites who move when I hit the arrow keys, according to this code:
Code:
int spd = 5; if ( keys[SDLK_UP] *&& (vikings1.yget() >= 200) ) { vikings1.yadd(-spd); } if ( keys[SDLK_DOWN] ) { vikings1.yadd(spd); } if ( keys[SDLK_LEFT] ) { vikings1.xadd(-spd); } if ( keys[SDLK_RIGHT] ) { vikings1.xadd(spd); } The problem that I have is that when I press and hold right, and then press left (or any other combination of opposite directions, the new one doesn't override the old one. Now, I did try something along these lines: Code:
if ( keys[SDLK_UP] *&& (vikings1.yget() >= 200) ) { *if (keys[SDLK_DOWN]) { vikings1.yadd(-2*spd); } *else { vikings1.yadd(-spd); } } So, how precisely would I get these keys to behave the nice, normal way (i.e. each keypress in an opposing direction overriding the last, regardless of hardware capabilities)? |
||
![]() ![]() |
|
![]() |
#2 | ||
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2004
Location: Jan Mayen, Svalbard and Jan Mayen
Posts: 2,167
|
![]() uhm if you keep a key pressed I think some keyrepeat is kicking in.
so the key "pressed" at a regular interval. there is a function that disables it.
__________________
Flowing with the stream of life |
||
![]() ![]() |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Done Quick | Skumpaq | Blah, blah, blah... | 1 | 21-11-2005 06:27 PM |
Help Plz Quick | Desperate one | Troubleshooting | 1 | 17-04-2005 06:16 PM |
Quick Art | TheVoid | Music, Art, Movies | 89 | 02-03-2005 11:31 AM |
Quick Question | 1988YJLaredo | Troubleshooting | 3 | 21-12-2004 05:54 PM |
|
|
||
  |