Jump to content
  • Advertisement

Archived

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

Gilzu

Smooth Scrolling, whats wrong here?

This topic is 6166 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

well, i''m trying to implement smooth scrolling, i.e. tiles move smoothly and not "jumping" so:
  
void CRTSMap::Draw(LPDIRECTDRAWSURFACE7 lpDD)
{
	int SmoothX, SmoothY;//this is how much to actually move the map

	SmoothX=dx%TILEWIDTH;
	SmoothY=dy%TILEHEIGHT; // grr, the problem

	
	int DeltaX, DeltaY;//this is how much whole tiles to change

	DeltaX=dx/(TILEWIDTH);
	DeltaY=dy/(TILEHEIGHT/2);
	if (DeltaY%2) DeltaY++;// this is to fix a "snake prob" ill xpand later


	int ScreenX, ScreenY;
	for (int CountY=0;CountY<47;CountY++) {

		ScreenY=(CountY*TILEHEIGHT);

		for (int CountX=0;CountX<12;CountX++) {
		
			if (CountY%2) {
				ScreenX=(CountX*TILEWIDTH);
			} else {
				ScreenX=(CountX*TILEWIDTH)+(TILEWIDTH/2)-TILEWIDTH;
			};
			
			if((-DeltaX+CountX>=0)&&(-DeltaY+CountY>=0)&&(-DeltaX+CountX<MapSizeX)&&(-DeltaY+CountY<MapSizeY))
//i know, for future reference: logicalmapx=-DeltaX+CountX logicalmapy=-DeltaY+CountY

				Tile->DrawTransparant(lpDD,ScreenX+SmoothX,ScreenY+SmoothY);
		};
	};
};
  
it work "smoothly" for the x axis, but for the y axis theres a "jumping" problem. i know its bcoz i fixed the snake prob, but dunno how to fix tha fix. i know how i sound, but its 4:44am here Gil p.s. snake prob: since my map isnt diamond, a column goes zigzag like staggered tilemaps (TANSTAAFL''s book abt isometrix). so this line is to fix a prob where the zigzag mirrors. p.p.s gotta get some sleep, plz help whoever reads so far and i''m not awake... i''m not making any sense now, am i?

Share this post


Link to post
Share on other sites
Advertisement
hmm.. methinks that ScreenY=(CountY*TILEHEIGHT); should be after the nested loop, not before. hope dat helps
~~KaMiKaZ~~

Share this post


Link to post
Share on other sites

  • 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!