Hello im currently learning SDL and i want to make a function in my program that shows the current position of the mouse ( x and y ) but when i try it it sais i cannot send in a string into the function that blits the surface i hope you understand what i mean im kinda tired and im not sitting by the computer that i got my source on so i cannot really explain so good.
how do you guys do it?
problem too Show mouse position in SDL
Moderator: Coders of Rage
-
- ES Beta Backer
- Posts: 61
- Joined: Sun Sep 21, 2008 4:46 am
- Location: U.K.
Re: problem too Show mouse position in SDL
Well, to get the current mouse position, you'd use an event.
For example:
Although, it sounds more like the error you're having is to do with the image blitting function, are you trying to pass a string where you should be passing an SDL_Surface?
For example:
Code: Select all
int MouseX, MouseY;
SDL_Event event;
while (SDL_PollEvent( &event))
{
if (event.type == SDL_MOUSEMOTION)
{
MouseX = event.motion.x;
MouseY = event.motion.y;
}
}
¡SÃ! ¡He dejado en libertad los prisioneros y ahora vengo por ti!
~El Pollo Diablo
~El Pollo Diablo
- KuramaYoko10
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Fri Oct 31, 2008 8:02 pm
Re: problem too Show mouse position in SDL
Hey dude,
I am learning C and SDL too...
And about your problem, I don't know if I understood right but you have several comands to manipulate the mouse, you have to look the SDL_mouse.h file!
One of them to look the exact position when this command is executed is this:
Now if you want to display every position of mouse on screen as you move it, you can go by where ChaosClown have pointed xD
Hope it helps!!
I am learning C and SDL too...
And about your problem, I don't know if I understood right but you have several comands to manipulate the mouse, you have to look the SDL_mouse.h file!
One of them to look the exact position when this command is executed is this:
Code: Select all
int x;
int y;
SDL_GetMouseState(&x, &y);
Hope it helps!!
Type a message here!!
[b][color=#BF0000]MarauderIIC[/color][/b] wrote:"Never" is never true in programming.
- M_D_K
- Chaos Rift Demigod
- Posts: 1087
- Joined: Tue Oct 28, 2008 10:33 am
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/++
- Location: UK
Re: problem too Show mouse position in SDL
you can also do:
I prefer this cause you get all mouse button states at the same time.
To check whech buttons are pressed you can use this
Code: Select all
//mouse_x and mouse_y are int
//mouseButtons are unsigned int
SDL_PumpEvents();
mouseButtons = SDL_GetMouseState(&mouse_x, &mouse_y);
To check whech buttons are pressed you can use this
Code: Select all
//button is stuff like SDL_BUTTON_LEFT, SDL_BUTTON_WHEELDOWN, etc
//the & is a bitwise and
//not to be confused with logical and which is &&
bool MouseBtnDown(int button)
{
return (mouseButtons&SDL_BUTTON(button))!=0;
};
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
Re: problem too Show mouse position in SDL
Thanks for your anwsers, i havent been able to try it cause my computer is fucked wich my stuff is on
i just wanted to let you know that i have recived your anwsers
i just wanted to let you know that i have recived your anwsers
TorteXXX