#### Archived

This topic is now archived and is closed to further replies.

# Not getting the correct tile coord for offset tiles

This topic is 5551 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

/\/\/\ \/\/\/ /\/\/\ \/\/\/ If the above is my map, there are 8 tiles there. Six of which aren''t offset, and two of which are. I''m having troubles getting the coordinate point of those offset tiles. The x value is fine, but I get 4 different y values depending on where I''m at in the tile. Here''s my code:
regX=int(x/64.0f);
regY=int(y/32.0f)*2;

mmX=x%64;
mmY=y%32;

And then I use the same mouse map as in TANSTAAFL''s tutorial pt. 1

##### Share on other sites
I find it hard to believe no one knows the answer to this

##### Share on other sites
I would be glad to help, only I''ve never done Iso, I just wanted to say that you have to be really patient in this forum. There aren''t that many of us still doing 2D

The more I think, the more confussed I get.

##### Share on other sites
Erm.. I dont know much isometrics but I can try help. I think I need more information than that, maybe a bit more code, the size of the tiles and what the variables represent

[edited by - Xtreme11 on July 31, 2003 2:46:50 AM]

##### Share on other sites
I haven''t really tryed this properly yet, but I''m figuring out the theory for myself. Not saying there''s anything wrong with your theory, I''m just comparing it to mine.

Why do you need those offset tiles? I would have thought you could just have something like:
 _ _ _ |_|_|_||_|_|_||_|_|_|

turned at a 45 degree angle. It looks pretty much the same as your''s, only at a different angle. Sorry if was a bit of a newbie reply, but I haven''t studied this much yet.

##### Share on other sites
But if you rotated it, you would still have offset tiles. The odd tiles would have their tops line up at say, 0, 32, 64, 96... While the even tiles would line up at say 16, 48, 80, 112... For my tiles I use a width of 64 and a height of 32. That''s about all the code there is to it. x and y refer to the mouse position. regX and Y refer to which region of the whole map the mouse is in, and mmX and Y refer to which region of an individual tile the mouse is in. A better explanation can be found at the bottom of the page here: http://gamedev.net/reference/articles/article747.asp

bump

##### Share on other sites
I''ve never used the method TANSTAAFL outlines in his tutorials and I''ve only ever skimmed through them once (that method for iso has always seemed counter-intuitive and needlessly confusing to me, but that is just my ever-so-humble opinion). However, I noticed that in your code above, you have the following lines:

regX=int(x/64.0f);
regY=int(y/32.0f)*2;

mmX=x%64;
mmY=y%32;

I couldn''t help noticing that you are mixing floating point and integer operations here, and I was wondering if that is what you intended. If your tile sizes are 64x32, is it necessary to have the floating point division in your regX/regY assignment expressions? Are x and y stored as floating points and cast to int somewhere? Modulus isn''t supported on floating point numbers, so if it compiles, I''m assuming x and y are either a) stored as integers, thus making the floating point divisions unnecessary, or b) stored as float and cast to integer, which can lead to problems with round-off/trunctation errors, and general wierdness in an iso if you''re not careful.

Anyway, if this doesn''t have anything to do with your problem, just ignore me or tell me to shut my yap.

Good luck

Josh
vertexnormal AT email DOT com

Check out Golem at:
My cheapass website

##### Share on other sites
My x and y are integers. The reason I casted the entire thing to an int was because that''s how the tutorial said to do it, and since my mouse coords were already integers, I guess I assumed he wanted to divide by a float otherwise there wouldn''t be a point to typecasting. I changed them to ints, and still no luck. Thanks anyway though.

##### Share on other sites
Okay...

Then, which Y are you getting the strange values for: regY or mmY?

Josh
vertexnormal AT email DOT com

Check out Golem at:
My cheapass website

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 13
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632927
• Total Posts
3009242
• ### Who's Online (See full list)

There are no registered users currently online

×