Advertisement

Mouse Selection Region Limiting

Started by
1 comment, last by dawidjoubert 18 years, 11 months ago
Hi there, Im writting a Basic RTS game so mouse selection is crucial.. prob is in windowed mode there arent constraints for the mouse and so play will not really be nice.. So how can i add constraints.. i imagined it to be something like SetCursorRegion(x,y,xx,yy) but i cant seem to find any thing on google... At the moment i use this code GetCursorPos(&mousePos); if (mousePos.x < rect->left) mousePos.x = rect->left; if (mousePos.x > rect->right) mousePos.x = rect->right; if (mousePos.y < rect->top) mousePos.y = rect->top; if (mousePos.y > rect->bottom) mousePos.y = rect->bottom; SetCursorPos(mousePos.x,mousePos.y); But its jumping as i dont get complete or rather Immediate Control over the mouse....
----------------------------

http://djoubert.co.uk
Why do you need to change the mouse position? As long as your game gets correct coordinates (which it does, since you correct them as you receive them), it should not care about where the actual cursor actually is. At the very least, make it an option that can be disabled, or you are prone to annoy your users a lot.

There is not a lot of control that can be had over the cursor position, simply because it is not yours: it's entirely managed by the operating system. In light of this, I seriously doubt any operating system would allow a program to restrict mouse movement. On the other hand, you can hide the cursor and keep it at all times in the middle of your window, and use the position changes to move a virtual cursor of your own across your window. Since you have control over THAT cursor, you can prevent it from leaving the window, and since you are actively keeping the real cursor in a fixed spot, you don't have to worry about it unless the user moves it too fast.
Advertisement
Quote: Original post by ToohrVyk
and since you are actively keeping the real cursor in a fixed spot, you don't have to worry about it unless the user moves it too fast.


Wether u understood or not i dont know but the point is that when my window has focus it needs to limit the mouse from leaving the ViewPort Area since consider wc3 or Starcraft where if ur cursor is on the edge of the screen the game scrolls...

Now imagine trying to scroll but yet u have to keep the mouse inside the box or what happens if u by accident click outside the box.. Boom Focus lost.


Means u could be losing a game while fooling aroudn with windows and stuff..

I know it can be done cause i have a program which runs Starcraft in window mode and it works for that...

Other wise perhaps i should skips windows and work directly with the interupt or mouse thingy.... But then i lose compatibality with other and new windows versions


----------------------------

http://djoubert.co.uk

This topic is closed to new replies.

Advertisement