RTS Mouse Scrolling?
BlitzMax Forums/BlitzMax Programming/RTS Mouse Scrolling?
| ||
Any ideas regarding mouse scrolling similar to RTS games? Is there any way we can grab the mouse but still register the distance of attempted movement past the screen boundaries? |
| ||
On fullscreen mode, and at least on Windows, when the mouse pointer is at the edge of the screen and you still move the mouse in that direction the operating system does not register a "mouse move" event, so to your application it will look like the mouse is stationary. What some games do, like Warcraft 3 for example, is to detect when the mouse is at the edge of the screen -- 8 possible directions, including diagonally -- and scroll the camera by a fixed amount. In Warcraft 3 you can edit this amount as the "Mouse scroll speed" setting. If you click and hold the mouse and then move the pointer outside of the screen, the camera starts moving and your selection area increases with this, so you can select units that are in an arrangement bigger than the viewport size by using this feature. The scrolling stops when you move the pointer away from the edge of the screen. |
| ||
That works. I can also do grab scrolling if people want to choose. |
| ||
You could also "reset" the mouse-position when "grabbing" - so the point of "grab start" is stored and then you move the mouse position accordingly. bye Ron |
| ||
Maybe I was being obtuse about screen edge scrolling but it seems like some games can tell how hard you moved the mouse against the edge. Are you talking about when it hits eg the upper edge, moving it back to the middle again invisibly, then keeping track of how far the mouse moves off center in an upward direction every tick, until it moves downward again ending the scroll? |
| ||
It is up to you how you implement your scrolling mechanism. to tell "how hard" the mouse was moved - you just store the distance and the time - so you get the speed, which could tell how "hard" (compared to an average "speed") the mouse was moved - and for you how to increase the scrolled distance according to the average. bye Ron |
| ||
There must be some way of determining mouse movement even when the cursor doesn't move anymore -- there are some 3rd party programs like "input director" that lets you control multiple computers with one mouse/keyboard, where if your mouse hits the edge of the screen it continues on the 2nd computer -- but it's still computer #1 that actually reads the mouse movements and relays them. |
| ||
Or Synergy. Edge hit detection with constant scrolling is sort of ok though. And if I can reset the mouse position to the center I can get a vector. |