Advertisement

Problem with isometric clipping/smooth scrolling

Started by August 24, 2001 01:55 AM
1 comment, last by Misogynator 23 years, 6 months ago
So smooth scrolling(and the clipping to make it look good) was easy with square tile maps, but for some reason I can''t quite get it to work with iso maps, except for the right side of the screen, which clips perfectly. I''m hoping there''s some obvious typo or something, so here goes:
  
void cTerrain::drawTerrain(DDBLTFX ddbltfx)
{	
	scrollX = worldCameraX / TILE_SIZE_X;
	scrollY = worldCameraY / (RHOMBUS_SIZE_Y / 2);
	
	offsetY = worldCameraY & (RHOMBUS_SIZE_Y / 2 - 1);
	offsetX = worldCameraX & (TILE_SIZE_X - 1);

	for (y = scrollY, screenY = 0; y <= scrollY + (SCREEN_SIZE_Y * 4); y++, screenY++)
	{
		
	        terrainSource.top = 0;//(terrainDesc[x][y] * TILE_SIZE_Y) + tOff;

		terrainSource.bottom = 32;//= (terrainSource.top + TILE_SIZE_Y) - bOff;

		
		terrainDest.top = (screenY * (RHOMBUS_SIZE_Y / 2 + 1)) - offsetY;
		terrainDest.bottom = terrainDest.top + TILE_SIZE_Y;		
		
		if (terrainDest.top < 0)
		{	
			terrainDest.top += -terrainDest.top;
			terrainSource.top = -terrainDest.top;
		}
		
		else if (terrainDest.bottom > (SCREEN_SIZE_Y * TILE_SIZE_Y))
		{
			terrainDest.bottom -= terrainDest.bottom - (SCREEN_SIZE_Y * TILE_SIZE_Y);
			terrainSource.bottom = terrainDest.bottom - (SCREEN_SIZE_Y * TILE_SIZE_Y);
		}
		
		for (x = scrollX, screenX = 0; x <= scrollX + SCREEN_SIZE_X; x++, screenX++)
		{
				

				terrainSource.left = 0;
				terrainSource.right = TILE_SIZE_X;			
			
				terrainDest.left = (screenX * TILE_SIZE_X + ((y & 1) * (TILE_SIZE_X / 2))) - offsetX;
				terrainDest.right = terrainDest.left + TILE_SIZE_X;

				
				if (terrainDest.left < 0)
				{
					terrainSource.left += -terrainDest.left;			terrainDest.left += -terrainDest.left;1) * TILE_SIZE_X /2);
				}
				
				
				else if (terrainDest.right > (SCREEN_SIZE_X * TILE_SIZE_X))
				{
					terrainSource.right += (SCREEN_SIZE_X * TILE_SIZE_X) - terrainDest.right;
					terrainDest.right += (SCREEN_SIZE_X * TILE_SIZE_X) - terrainDest.right;
				}
				
				
				
				g_DDSBack->Blt(&terrainDest,
				g_DDSSprites1,
				&terrainSource,
				DDBLT_WAIT | DDBLT_KEYSRC | DDBLT_DDFX,
				&ddbltfx);
				

		}
		
		
	}

}
  
this line:
  terrainDest.left += -terrainDest.left;1) * TILE_SIZE_X /2);  


obviously has a typo - everyhing after the 1st semicolon was a commented line that was only partially deleted. Plus the whole statement should be on the next line, obviously. Sorry bout that.
Advertisement
ermm..heh there needs to be an edit message option. Anyway, the last post wasn''t to say I fixed it, rather it was just a clarification.

This topic is closed to new replies.

Advertisement