   Character position and scrolling maps
  I''ve looked at all of the "smooth scrolling" tutorials, and I can''t understand it fully. I''ve gotten it to work once, but by accident, and I don''t want to move on until I understand it. The major problem I had was it looked HORRIBLE.This is my tile information:Tiles are 32x32Maps are (in tiles) 100x100The screen (in tiles) is 25x19(rounded up from 18.75)The screen''s resolution is 800x600I want the player to be centered in the screen unless the screen is at the edge of the map. Any help would be appreciated!   /*I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition)*/ 
  I am assuming you are using some sort of camera object. This is usually only a simple POINT struct in most tutorials (i.e. an x,y coordinate)and possibly a set of limits like (0,0)-(100,100). Anyway, the camera represents an offset value from the center (your char) of the screen to the top left corner of the screen. The camera is in pixel coordinates for smooth scrolling so that we appear to gradually move from one tile to the next. If this were per tile scrolling, we could use tile coordinates instead but that looks jumpy and isn't very pretty. When it comes time to draw your tilemap, you convert from pixel to tile coordinates to figure out which tile to start drawing from. To allow your player to move to the corners without the map moving, just limit your camera to a minimum of 0,0 and a maximum of (map width in pixels - screen width, map height in pixels - screen height).[edit] whoops, messed that up a little, fixed it I thinkI hope that helps. I have a smooth scrolling tilemap I wrote a while ago but it wraps instead of stops at corners. You can have a look at it here and if you want I can e-mail you the source if I can find it. It uses DirectDraw but the concepts should be the same in any 2d tilebased scroller.  Evillive2E-Mail [edited by - evillive2 on February 9, 2004 7:41:27 PM];  That is exactly what I want. If you do find it, could you please e-mail it to me at Programmer16@msn.com. Thank you very much!   /*I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition)*/ ;  ok, I will take a look for it when I get home from work tomorrow. Its not that difficult. The bulk of the code is gfx/api setup and parsing the .map and .ini files which won''t be much use to you, but the map drawing part is basicly the same as the tutorials except I used my own clipping routines to clip the source rectangles of stuff that needed clipping. But anyway, I will post it here if I can find it just in case anyone else wants to look at it and tear it to shreds.  Evillive2E-Mail;Here is the source for that scrolling tilemap. It isn't much but I hope it helps you out.  Evillive2E-Mail [edited by - evillive2 on February 10, 2004 9:11:16 PM] [edited by - evillive2 on February 10, 2004 9:12:50 PM] [edited by - evillive2 on February 10, 2004 9:14:18 PM]