Not getting the correct tile coord for offset tiles

Started by
10 comments, last by Sfpiano 20 years, 8 months ago
/\/\/\ \/\/\/ /\/\/\ \/\/\/ 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
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Advertisement
I find it hard to believe no one knows the answer to this
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
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.
JRA GameDev Website//Bad Maniac
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]
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.
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
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
bump
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
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
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.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
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

This topic is closed to new replies.

Advertisement