Jump to content
  • Advertisement
Sign in to follow this  
Holland

some help picking in ortho2D

This topic is 3621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Basically I'm trying to keep it all 2D and I have the window split into a grid of tiles. I want to be able to click on the grid and pull the ortho coords out of the mouse click so I can process the tile that was clicked. Idealy I want mouse hovering to trigger certain behaviours on the tiles, but clicking will work for now if that's easier. I'm not using glut..first of all, so no glut please. :) And also, I have done picking of 3D objects by rendering out in select mode...but i'm not sure how that would worth in ortho2D. Thanks in advance! Edit: I'm just using... case WM_LBUTTONDOWN: Select(LOWORD(lParam), HIWORD(lParam)); break; ... for now...but I'm still hoping to figure out a way to just test if the pointer is hovering? [Edited by - Holland on July 20, 2008 10:45:01 PM]

Share this post


Link to post
Share on other sites
Advertisement
Since this is 2D and well Windows is 2D, you could just use GetCursorPos() (http://msdn.microsoft.com/en-us/library/ms648390(VS.85).aspx) and offset it with the upper left coord of GetWindowRect() (http://msdn.microsoft.com/en-us/library/ms633519.aspx). That will give you the Cursor's position on the screen. You can offset it again using wherever your camera is.

Since this is tile based, take the X,Y from that and you can easily find which tile the cursor is over. If it's hovering over a tile w/ and object, trigger the hoveraction. If user clicks on object, trigger that.

Share this post


Link to post
Share on other sites
Quote:
Original post by cmptrgy412
Since this is 2D and well Windows is 2D, you could just use GetCursorPos() (http://msdn.microsoft.com/en-us/library/ms648390(VS.85).aspx) and offset it with the upper left coord of GetWindowRect() (http://msdn.microsoft.com/en-us/library/ms633519.aspx). That will give you the Cursor's position on the screen. You can offset it again using wherever your camera is.


Or you could use ScreenToClient() on GetCursorPos()'s return value

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!