Jump to content
  • Advertisement

Archived

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

kooktroop

Scrolling, Edge Problem

This topic is 5546 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:
tileX--; 
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!