Jump to content
  • Advertisement

Archived

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

Sfpiano

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!