Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / Game Design & Programming / Basic 2d tile scrolling Need some help Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

May 13, 2005, 12:59 AM

Okay I really can not figure out whats wrong here but my tiles are not smooth scrolling and I really cant figure this out. Anyone have anything similiar? I need some advice on what im missing. The screen keeps going back to the center after I scroll like one tile. Any ideas?

  2. void DrawTileMap(ID3DXSprite &mapsprite,int tiledimx,int tiledimy,RECT &rect,CGRAPHICS *anobject)
  3. {
  5.         //Load Level file using FILE I/O store in structure
  6.         int scrollx=worldx/tiledimx;
  7.         int scrolly=worldy/tiledimy;
  9.         int offsetx=worldx % tiledimx;
  10.         int offsety=worldy % tiledimy;
  12.         //Draw Screen
  13.         for(int y=0;y<numtilesy+1;y++)
  14.         {
  15.                 for(int x=0;x<numtilesx+1;x++)
  16.                 {
  17.                         tilecoord.x=(x*tiledimx)-offsetx;
  18.                         tilecoord.y=(y*tiledimy)-offsety;
  20.                         char tile=map[y][x];
  22.                         //I Assume tilelookup is working right
  23.                         TileLookUp(97,32,32,tile,rect);
  24.                         mapsprite.Draw(anobject->pTexture,&rect,NULL, NULL, 0.0f,&tilecoord,0xffffffff);
  25.                 }
  26.         }
  27. }


May 13, 2005, 01:19 AM

You forgot to actually use the scrollx and scrolly variables you calculated in the first rows.


May 13, 2005, 01:41 AM


char tile=map[y + scrolly][x + scrollx];

will do the trick I guess... ;)


May 14, 2005, 07:13 PM

Thank you much. I spent a long time trying to figure this out. What a dumb mistake thanks for the help.

This thread contains 4 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.