-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|685|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- Socoder -> C/C++/C#/Other -> Reverse tile map? Posted : Monday, 27 April 2015, 23:51 spinal OK, everyone knows it's super easy to grab a tile number from a map eg, int tile = map[x+width*y]; --v But how the hell do i do it the other way? That is get an x,y from a tile number? I'm currently trying this - for(int y = 12; y>0; y--){ for(int x = 10; x>0; x--){ int tile = MaxMap[x+10*y]; int x1 = ((tile/4)*8); int y1 = ((tile%4)*8); graphics_draw_bitmap_in_rect(ctx, max_white_bitmap, GRect((x*8)-x1, (y*8)-y1, 8, y1+8)); } } --v That graphics_draw_bitmap_in_rect basically just plonks the whole image down at (x*8)-x1, (y*8)-y1 and clips the right/bottom. I don't know if it's open source or not, so I haven't looked into a better way of clipping the top/left yet, so this'll do. Anyway, does that look right to you guys? The map image (max_white_bitmap) is 32x872 pixels (10x61 tiles). -=-=- Check out my excellent homepage! Posted : Thursday, 08 October 2015, 03:46 spinal Where's this thread gone? Posted : Thursday, 08 October 2015, 04:29 Jayenkai *shrugs* No idea where/why that vanished. Weird.. Could've been something to do with when I was changing the server, or when the site broke that time. Not a clue. -=-=- ''Load, Next List!'' Posted : Thursday, 08 October 2015, 04:33 Jayenkai If.. x=5 y=15 width=32 Tile=(y*width)+x --v Then.. Tile=45 Width=32 x=Tile Mod Width (or Tile % Width in none-Basic's) y=Floor(Tile / Width) --v -=-=- ''Load, Next List!'' Posted : Thursday, 08 October 2015, 06:04 rockford Yep that's how I would have done it too. I used to do that in DIV.