Jump to content
  • Advertisement
Sign in to follow this  
Darkbouncer4689

Determining Click Position of 2D perspective board

This topic is 2609 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

Hey all,

I'm messing around with Flash and making a little chess game. I need to determine which box on the board the user has clicked on so that I can move pieces around. I've thought of two possible solutions to this.

1) Treat each box on the board as an individual sprite and add a click event listener to each box.

2) Based on the dimensions of the board and the mouse coordinates, use a bit of math to determine what box the mouse is over.

I'm thinking number 2 is a better solution then to have 64 (8X8) individual sprites with individual event listeners. The problem I'm facing is that the board is a perspective board, meaning to achieve the illusion of depth the dimensions of the board are warped.

It seems like the perspective illusion is accomplished by each column of the board having a unique slope to it, the leftmost column has the steepest negative slope while the center column has a slope of 1 and the rightmost column has the highest positive slope.

Anyone have any suggestions on how to tackle this problem?
Thanks!

Share this post


Link to post
Share on other sites
Advertisement

It seems like the perspective illusion is accomplished by each column of the board having a unique slope to it, the leftmost column has the steepest negative slope while the center column has a slope of 1 and the rightmost column has the highest positive slope.


To me this sounds like you are using some "hand-created" algorithm that mimics proper 3D perspective projection.

I would try to represent that 3D->2D mapping as perspective projection. Perhaps something similar to this. After you have written down the perspective projection mapping, you can invert that mapping to produce the point on the original perspective-skewed rectangle.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!