[SDL] confused by SDL_KEYDOWN event!!!

Jonathan Dearborn grimfang4 at hotmail.com
Thu Oct 11 09:28:29 PDT 2007


Hey,
 
My suggestion would be to use SDL_PollEvent() in a while loop so that you catch and handle every event that hops on the queue.  You're probably ignoring all events but one each frame.
 
void Tank::HandleInput( SDL_Event &event,bool &run){
 while(SDL_PollEvent(&event))
  {
        ...
  }
 
}
 
 
Jonny D
 
 
 


Date: Thu, 11 Oct 2007 22:29:32 +0800From: dh11111 at 126.comTo: sdl at lists.libsdl.orgSubject: [SDL] confused by SDL_KEYDOWN event!!!
here is my code:
 void Tank::HandleInput( SDL_Event &event,bool &run){
 SDL_PollEvent(&event);
 
...
}
 
 
problem is that when i keep pressing a key such as "a", the tank in my game keeps moving left,but if i move the mouse during the tank's moving,the tank stops moving.
In the doc it seems that there are  some differences between  SDL_KEYDOWN  and SDL_MouseMotionEvent,but in my application ,it seems there no differences between them!
 
what's the difference between these two event type? it seems a little confused.
PS: My OS is Windows xp,SDL version is 1.2.12,IDE is VS 2005 PRO.
 
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20071011/9a09d31b/attachment.html 


More information about the SDL mailing list