Originally posted by karl nilsson:
yes, it is fixed, and thankfully I have managed to get my solution working somewhat, but I think I'll look into that 3D math (not for this project)
thanks for your help
You really don't need 3D math. Just 2D would work.
The isometric view using implies a certain tansform matrix (or series of equations) to go from the (R)ank and (F)ile measurements of your chess board to the X and Y on the screen. For instance, I could see you using...
Now what you need is the reverse transform to get from an X,Y screen coordinate of a mouse click to rank and file. To get that, you can solve the X and Y equations for R and F. Finding the inverse of the transform matrix solves the same problem.
Let's try one. The home square for White's king pawn covers a range of Rank values of [1,2]. (The integer values for Rank and File give the corners of each square.) The File values are [4,5].
The four corners for that square will be drawn on the screen at...
(1,4) --> (201,55)
(1,5) --> (218,65)
(2,5) --> (201,75)
(2,4) --> (184,65)
Notice those four points make a squashed diamond shape on the screen.
Let's say the user clicks right in the middle of that space. Using the inverse equations/transform matrix (X,Y)=(201,65) converts to (R,F)=(1.5,4.5). Sure enough that's right in the middle of Whites king's pawn's home square.
As another example, let's say the user clicks at (X,Y)=(217,56), which is outside the diamond shape but just barely within its bounding box. That screen coordinate converts to (R,F)=(0.58, 4.52). This is in the white king's home square.
Cool?