   2D Tile based checks
  I have tilesets, each tile is 32x32, and characters sets, each tile is also 32x32. I want the character to move pixel by pixe, but I can't figure out how to check and see if he is trying to walk on something that he can't (i.e. a wall or tree). With tile-based I would just access my array and with my algorithm, check the tilenumber. But this won't work. I have a theory but it isn't finish://In my player class add an index:int m_iUDMovementIndex; //For up/downint m_iLRMovementIndex; //For left/right//And then in my moving function add/subtract 1 for directionvoid MoveDown(){ int UpDown = m_iUDMovementIndex + 1; if(UpDown <= 0 || UpDown >= 32) {  m_iRow++; } if(g_pMap[(m_iRow * NumberOfColumns) + m_iColumn)] == BLOCKABLE) {  return; }}  Would or wouldn't this work? If anybody knows I would appreciate it.[edited by - Programmer16 on September 22, 2003 10:34:20 PM]
  Hi,Actually, pixel by pixel movement is quite easy. To find the tilenumber all you have to do is to divide your character position in pixels by the tile size. Thus,if your character is at position (75, 214)I assume your map starts at position(0,0)tilenumberX = 75 / 32 = 2.34.. then round to the lowest integer so it is 2tilenumberY = 214 / 32 = 6.68..   ""   so it is 6your character is at position (2,6)hope that helps   [edited by - darkneon on September 22, 2003 10:50:11 PM];  Thanks, I''ll try this. ;  I tried this, and the only problem is if you are half way onto a tile, this sets it to the the tile you are moving onto. If you stay here you can walk over any tile that is in the column you are moving from. Same thing for the row.   /*I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition)*/ ;  You''ll need to constrain the character per pixel.If your character is in a free tile, and the tile to it''s right is blocked, you''ll need to clamp character movement to that tile''s left boundary. Something like the tile width multiplied by the amount of tiles to the left of that tile that are visible in the screen. You then check that against the characters right boundary. ;  i''ve written a tutorial on tilebased collision detection and response:http://jnrdev.kbs-design.net/en/jnrdev1[Edited by - no_skill on February 10, 2005 1:49:23 AM]