Original Post
well im trying to make an isometric tile based game using mostly javascript, and i got the map painted and a functional array that stores tile positions, but im having trouble capturing mouse events.
so the real problem is, i can't figure out a way to manipulate the x and y coordinates where i click, and turn them into a number that fits any posible map size, for example
i have a map of 'a' rows and 'b' columns, and i get the tiles stored in a 2 dimensional array, so lets say each tile is 64x32 pixels and i got a 10x10 map, which would use 640x320 pixels.
then there is the problem, when i click anywhere on the map, im capturing the xycoordinates and i can't figure out a way to turn those coordinates, into numbers from 0-9 (for this example), to use them to know which tile im click in on.
i have read a lot of guides on the subject, and i haven't been able to find one that actually works, or that i can understand.
also im not planing to have plain maps, they are going to have like levels or floors and some tiles are going to be placed over other tiles, and so on, so if there is anything i should take into consideration when clicking on that kind of map with floors, it would be welcome as well, even tho i can't really advance on it until i get it to click on plain maps.
thank you in advance and i'd like to point out that i've found some guides on the subject, but i find them really hard to understand, so any help would be appreciated.
so the real problem is, i can't figure out a way to manipulate the x and y coordinates where i click, and turn them into a number that fits any posible map size, for example
i have a map of 'a' rows and 'b' columns, and i get the tiles stored in a 2 dimensional array, so lets say each tile is 64x32 pixels and i got a 10x10 map, which would use 640x320 pixels.
then there is the problem, when i click anywhere on the map, im capturing the xycoordinates and i can't figure out a way to turn those coordinates, into numbers from 0-9 (for this example), to use them to know which tile im click in on.
i have read a lot of guides on the subject, and i haven't been able to find one that actually works, or that i can understand.
also im not planing to have plain maps, they are going to have like levels or floors and some tiles are going to be placed over other tiles, and so on, so if there is anything i should take into consideration when clicking on that kind of map with floors, it would be welcome as well, even tho i can't really advance on it until i get it to click on plain maps.
thank you in advance and i'd like to point out that i've found some guides on the subject, but i find them really hard to understand, so any help would be appreciated.