SDL_MOUSEMOTION

Started by
3 comments, last by Rastamanbegood 10 years, 4 months ago

First post ever woop!

Let's say I use SDL_MOUSEMOTION. If I run the application and never move my mouse over my SDL window. Are the mouse coordinates 0, 0 by default? So if I have a player that would "follow" the mouse, would that player move towards 0,0 automatically? Even though I never really made a mouse motion.

Advertisement

Well considering SDL_MOUSEMOTION is an event, then the event would get triggered whenever your mouse is moved. There shouldn't be a mousemove event popping up when the application first starts up (unless you move the mouse of course). I'm not sure what the default x and y of the mouse would be (I'd assume it would be wherever the mouse currently is within your app) but if you want a specific starting point, you can have a variable that is initialized to what you want.

Worst case scenario, just make small sdl program that prints out the mouse value to cout or something. Then you'll have your answer.

Thank you for the reply.

The reason i'm asking is, my "player" starts drifting off to 0,0 when the application starts if I never move the mouse inside of the sdl window. If I move the mouse inside of the window "player" starts to follow the mouse just fine. It's like there is magic invisible mouse at 0,0. :D

Thank you for the reply.

The reason i'm asking is, my "player" starts drifting off to 0,0 when the application starts if I never move the mouse inside of the sdl window. If I move the mouse inside of the window "player" starts to follow the mouse just fine. It's like there is magic invisible mouse at 0,0. biggrin.png

Does your own local mouse-position variables start at (0,0)? When do you tell your character to start moving? If your character is always moving, and your local mouse position variables are (0,0), then your character would likely move towards that.

The fog is clearing. Thanks :)

This topic is closed to new replies.

Advertisement