   Tile number algorithim
  Hello, I''m working a 2d tile based strategy game and I have a problem with my algorthim that I use to name tiles, and to retrive that tile from the texture list.my map consists of an array of numbers, those numbers are used to retrive the correct texture to draw on the tile. Now the base number of each texture is 5, starting at 10 and in the map file tiles are numbers as X0,X1,X2,X3 which corrsipond to a rotation of the texture.  Each texture also a mask file for blending.So textures are named tile10.bmp, tile10_m.bmp, tile15.bmp, tile15_m.bmp and so.tile 10 corrisponds to texture 5, and tiles 15 corrisponds to texture 6.my program does the following (tileNum mod 5) to determine the orientation. Then (tileNum/5)+3 to get the appropreite texture.Unfortunetly for values higher then 40, it stops working properly and starts picking the wrong texture.So I need a new algorithim for numbering tiles and retriving textures.   -----------------------------------------------------Writer, Programer, Cook, I''m a Jack of all TradesCurrent Design projectChaos Factor Design Document
  You're trying to "encode" too much information in your tile number, which is especially a problem when it's done algorithmically, because it becomes near impossible to find a suitable number that can be interpreted in all the unique ways you need to be, as you have more tiles.There are several ways to get around this, if you are really adamant about having that tile number store all the information it can, then do it with bit manipulation and shifting.  That way, you actually make use of the raw storage that a variable has to offer, rather than the actual value's mathematical properties.  To human eyes, the number might seem large an meaningless, but bitwise it has unique meaning.  Or, you can have an array of structures of objects, rather than integers, that describe each tile.  However you want to do it is fine.   [edited by - Zipster on August 2, 2003 3:26:49 AM];  The problem with what your suggesting is I want the map files to be very easy to make. In the current state they are just strings of numbers.17,13,1812,00,1016,11,15Under my current system that would create a map consiting of a water tile surround by grass.I can''t think of way to do what your suggesting without completly redesigning my map class. And also doing what your suggesting would change the whole way I create those maps. -----------------------------------------------------Writer, Programer, Cook, I''m a Jack of all TradesCurrent Design projectChaos Factor Design Document ;  I don''t see any reason why it should fail above 40. How is it failing? 