Thursday, 8 August 2013

SDL - Why moving the mouse changes button state?

SDL - Why moving the mouse changes button state?

I'm having a problem with the Simple Directmedia Layer library. The
following code expands a point on the screen when a mouse button is
pressed:
while(event.button.state == SDL_PRESSED){
SDL_PollEvent(&event);
++point.x;
++point.y;
//Draw to screen
SDL_FillRect(display,&point,pointColor);
SDL_Flip(display);
}
It works fine until I move the mouse, why moving the mouse makes
event.button.state untrue?
How can I work with both simultaneously (i.e. to move an object or draw)?

No comments:

Post a Comment