Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / converting pt(x,y) to isometric tile ordered pair

Author
Message
Dan Fessler
16
Years of Service
User Offline
Joined: 17th Feb 2008
Location:
Posted: 27th May 2009 22:45


the top portion of the image shows how to find the tilex and tiley of a point given the tilesize. tile = int( pt / tilesize ) + 1
I want to perform this same type of operation on an isometric grid given a constant 2:1 tile ratio, and origin is the top corner of the isometric grid.

I'm assuming I should stretch the isometric grid vertically x2 then rotate it counterclockwise by 45 degrees, then finally perform my original equation - but I am unsure how to do this. Can anyone help?

Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 29th May 2009 00:01
Most isometric games don't start with a top down map and convert each tile to isometric... they just start out isometric because converting usually makes the tiles look bad. On your picture it shows the actual x and y coordinates of the red dot. With isometric games you only need to know the map x and y of the dot since the actual x and y (to the screen) changes when you scroll the map. The red dot is at 2,1. Attached is the way Ultima Online tiles look.

Attachments

Login to view attachments
Dan Fessler
16
Years of Service
User Offline
Joined: 17th Feb 2008
Location:
Posted: 29th May 2009 03:32
I am aware of the nature of isometric view games. I think you misinterpreted the question I had. the top portion of the image is not how my game looks at all. its simply an example of the type of operation I wish to perform - which is returning a tile(x,y) for any given pixel point. This type of operation is especially useful when determining perfect player-to-tile collisions. It's just much harder to do on an isometric grid.

in order to mathematically determine which tile a pixel point would reside on an isometric grid, my first guess would be to convert the isometric map to a traditional grid (in *memory*, not actual display).

I've finally got a working function. You plug in a pixel point, it multiplies it's y-height by 2 to be in sync with perfect diamond tiles (much like the ultima online tiles), then rotates the point 45 degrees counter clockwise from the map's origin to be aligned to a theoretical straight grid. This grid doesn't really exist, but it's how I can calculate what tile a pixel resides. from this point I perform my original equation as demonstrated in the upper portion of the image. tile = int(pixel_position/tilesize)+1. Tilesize is determined by measuring the hypotenuse of one quarter of the isometric tile.

here is the function for those who are interested...



Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 29th May 2009 09:44
Yeah I was way off. I'm glad you got it working though.

Login to post a reply

Server time is: 2024-05-01 23:27:17
Your offset time is: 2024-05-01 23:27:17