Original Post
Okay, my SDL 2d tile engine is properly finished. Very nice it is too.
This piece of code below worries me however, is there anyway (short of using precalculated globals and the like) that I can use bitshifts or something here? Thats a little over my head to figure out for the time being
The code sets an SDL_Rect, ''tile_src'' using the tile index from the map -- Heres the code:
Any << >> type ideas?
Thanks,
Paul.
tile_src.x = tile % TILES_PER_ROW * TILE_SIZE; tile_src.y = tile / TILES_PER_ROW * TILE_SIZE; tile_src.w = tile % TILES_PER_ROW * TILE_SIZE + TILE_SIZE; tile_src.h = tile / TILES_PER_ROW * TILE_SIZE + TILE_SIZE;''TILE_SIZE'' is a macro defined as ''32'' for this example. ''TILES_PER_ROW'' is the number of tile images per row in my tileset, its set to ''4'' in this example. My tileset image is square and a power of two, ready for you guys to work your bitshifting magic
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..."