polarboy 145 Report post Posted August 10, 2008 Well, I'm still working on the top half of my map, to figure out which tile my mouse clicked on. I think this approach would work, but it yields ridiculous numbers. My approach is as following: Since my tiles are 64 * 32, and I set (0,0) at (512,0) screen coord. I create an equation for the left most line: x = -2y + 512; Then I create an equation for my mouse, x = 1/2y + N; and then I figure out the N and find point of intersection -2y + 512 = 1/2y + N; so I find y, and use that y to find the x at Point of intersection. To find the isometric x, I look at how many 64s is the x at P.O.I away from 512 and to find y, I look at how many 64s is the mouse x away from the P.O.I x I think this method makes perfect sense, but it's simply not working right now. Anyone see anything wrong with it? 0 Share this post Link to post Share on other sites
LorenzoGatti 4442 Report post Posted August 11, 2008 Your explanation isn't very clear. Quote:Then I create an equation for my mouse, x = 1/2y + N;The mouse cursor is not constrained to a certain line. What is N? Moreover, what are the tilemap's conventions? Are you perhaps mixing up screen pixel coordinates and tilemap coordinates? 0 Share this post Link to post Share on other sites
Luctus 584 Report post Posted August 11, 2008 I don't understand what you mean, but I can assure you that linear algebra works perfectly fine for isometric projections.Assuming your tiles are 64 pixels wide and 32 pixels high, your world x-axis is pointing down and right on the screen, world y-axis is pointing down and left: ---------------------------------> screen x-axis| /\ | / \ | / \ | / \ | world |/_ _\| world| y-axis x-axis||Vscreen y-axis You'll get a projection matrix (projecting world coordinates to screen coordinates) as follows:[32 -32][16 16]Your world (x,y) projected into screen coordinates (x',y') and adjusted 512 pixels will bex' = 32*x - 32*y + 512y' = 16*x + 16*yWhen you want to find out where in world-coordinates your mouse cursor is, you use the inverse of the projection matrix:[ 1/64 1/32][-1/64 1/32]To calculate the mouse position in world coordinates (x',y') from it's screen coordinates (x,y):x' = (x-512)/64 + y/32y' = -(x-512)/64 + y/32// Edit: a bit of a miscalculation fixed[Edited by - Luctus on August 11, 2008 11:30:51 AM] 0 Share this post Link to post Share on other sites
polarboy 145 Report post Posted August 12, 2008 Quote:Original post by LorenzoGattiYour explanation isn't very clear. Quote:Then I create an equation for my mouse, x = 1/2y + N;The mouse cursor is not constrained to a certain line. What is N? Moreover, what are the tilemap's conventions? Are you perhaps mixing up screen pixel coordinates and tilemap coordinates?oh, I'm setting up an equation of the line perpendicular to the x = -2y + 512 line that goes through the point where the mouse is atIt doesn't really concern the tilemap tho, cuz I was just taking the mouse coordinate and use the equation to figure out which tile it should beI put on a tilemap, but that's only for visual aid[quote]Original post by LuctusI don't understand what you mean, but I can assure you that linear algebra works perfectly fine for isometric projections.Assuming your tiles are 64 pixels wide and 32 pixels high, your world x-axis is pointing down and right on the screen, world y-axis is pointing down and left:You'll get a projection matrix (projecting world coordinates to screen coordinates) as follows:[32 -32][16 16]Your world (x,y) projected into screen coordinates (x',y') and adjusted 512 pixels will bex' = 32*x - 32*y + 512y' = 16*x + 16*yWhen you want to find out where in world-coordinates your mouse cursor is, you use the inverse of the projection matrix:[ 1/64 1/32][-1/64 1/32]Lol, I need to catch up on linear algebra :(summer made me forget everything, I was actually doing somethign simpler 0 Share this post Link to post Share on other sites