• Advertisement


This topic is now archived and is closed to further replies.

Scrolling, Edge Problem

This topic is 5366 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, ive implemented a scrolling algorithm. The main variables are calculated like so:

/* tileX|tileY : tile in the top left hand corner
   offsetX|offsetY : ''prestep'' or the amount of pixels to offset the tiles by
   finishX|finishY : the tile coordinates of the bottom-right tile

// calculate the top-right tiles, >> = divide

tileX = drawX / m_TileWidth;
tileY = drawY / ( m_TileHeight / 2 );

// calculate the offsets

offsetX = drawX % m_TileWidth;
offsetY = drawY % ( m_TileHeight / 2 );

finishX = tileX + 20; // tileX + max amount displayable

finishY = tileY + 20; // see above

if ( finishX > m_MapWidth )
	finishX = m_MapWidth;
if ( finishY > m_MapHeight )
	finishY = m_MapHeight;
now this is great and all it smooth scrolls to a certain extent... But when tileX is increased there is a ''gap'' or blank space down the edge of the screen because the tiles in the column preceeding it are no longer displayed. I simple:
wont work because then the offset is out of place. Any ideas on how to fix this edge problem?

Share this post

Link to post
Share on other sites

  • Advertisement