Skip to main content
GameDev.net gamedev.net
🔒 Locked

RTS Camera

Started by Worthless_Knowledge Jan 19, 2004 at 9:45 AM 3 replies 2.1k views
Original Post
Worthless_Knowledge
Worthless_Knowledge
I am going to try to make a simple rts style game and was wondering about the camera. I think im gonna have it so when the mouse goes near the edge of the screen the camera moves in that direction. Now what would be the best way of getting the mouse position(DirectInput, GetMousePos) ?
James Gregory
James Gregory
If it's a simple RTS game, GetMousePos is just fine.

Direct Input allows you to track direction of travel and such like, GetMousePos just gives you the screen coordinates of the cursor. For a simple RTS game you scan make do simply with a

if mousePos.x > screenWidth -5
then scroll right

if mousePos < 5
then scroll left

etc

[edited by - James Gregory on January 19, 2004 12:20:41 AM]
Dak Lozar
Dak Lozar
After playing C&C:Generals for more than two minutes with a dual monitor setup you''d get tired of trying to position the mouse precisely within that range on the left (or right side of the screen depending on your dual monitor setup) side of the screen.

Make sure you use the windows.left or windows.right coordinates when implementing your mouse move functionality... I''ve not written any code that works on a dual monitor setup (yet) but I''d be welcome to test for you

Rise of Nations, does handle the mouse positioning properly so it can be done.

Dave Dak Lozar Loeser

"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
bmarci
bmarci
Use the ClipCursor() (Win32Api)
Remember to call again in case of Alt-tabbing-back

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.