Tile Engine Math

Started by
4 comments, last by TwisteR 19 years, 7 months ago
Hello again, lol. i know i've been asking alot on these forums lately, and its been a really big help, and i'd like to thank everyone who helped. Now, for the question. ok, im building a tile engine that uses 32x32 tiles, there set up in a 13X13 grid. Now they are arranged by index number (0,1,2,3...168) and i need to access them by the x,y co-ords. i know how to get the Index number from the x,y co-ords ((y*width)+x = index), however i dont know how to get the x,y from the index. can neone help on this? thanks.
------------------------------------Mitch Mulholland----------A.K.A.= TwisteR---------------------------------------
Advertisement
y = (index / 13);
x = (index % 13);

throw table_exception("(? ???)? ? ???");

thanks
------------------------------------Mitch Mulholland----------A.K.A.= TwisteR---------------------------------------
lol sorry, but what is the %? it comes up with an error, it isnt X * 0.13 is it?
------------------------------------Mitch Mulholland----------A.K.A.= TwisteR---------------------------------------
% is the modulus in C++, it gives the remainder after dividing the numbers
Oh, ok. thnx. lol its been a long time since i've done C++. lol. sorry bout the stupid q
------------------------------------Mitch Mulholland----------A.K.A.= TwisteR---------------------------------------

This topic is closed to new replies.

Advertisement