![]() Pick up a book on Algebra or read some online tutorials, you will thank yourself later. Solving linear equations comes very much in handy for a lot of programming, especially graphics or game related programming. In following simple code snippet, we assume the user initiates multiple touch contacts on an element with an id of source. The Touch.screenY property is the vertical coordinate of a touch point relative to the screen in CSS pixels. IsoY = screenY / tileH - screenX / (2*tileW) The Touch.screenX property is the horizontal (x) coordinate of a touch point relative to the screen in CSS pixels. ![]() IsoX = screenY/tileH + screenX / (2*tileW)Īnd finally, substitute isoX in line B, with the formula derived from line A: isoY = 2*screenY / tileH - screenX / tileW - isoYĢ*isoY = 2*screenY / tileH - screenX / tileW IsoX = screenX / (2*tileW) + screenY/tileH IsoX+isoX = screenX / tileW + 2*screenY/tileHĢ*isoX = screenX / tileW + 2*screenY/tileH Then substitute isoY in the line A, with the formula derived from line B: isoX = screenX / tileW + 2*screenY/tileH - isoX Pick up a book on Algebra or read some online tutorials, you will thank yourself. Now the two lines look as follows: A) isoX = screenX / tileW + isoY isoY 2screenY / tileH - screenX / tileW - isoY 2isoY 2screenY / tileH - screenX / tileW isoY screenY / tileH - screenX / (2tileW) Solving linear equations comes very much in handy for a lot of programming, especially graphics or game related programming. I am trying to run a method whenever the screenX or screenY position of a rendered window changes. The second line: screenY = (isoX + isoY) * tileH / 2 Starting with the first line you get the following: screenX = (isoX - isoY) * tileW To get this function you need to rewrite the original math screenX = (isoX - isoY) * tileW Var isoY = screenY / tileH - screenX / (2*tileW) Var isoX = screenY / tileH + screenX / (2*tileW) ![]() Var screenToIso = function(screenX, screenY)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |