Advertisement

Tanstaafl Iso Blt and MouseMap

Started by January 10, 2001 09:14 AM
-1 comments, last by PsYchOtroW 24 years ago
Hi, i have some problems with his methods. I am using this Drawing Method:
  
	int WhereX; // Where are we currently rendering on the map?

	int WhereY;

	WhereY = WorldY;
	WhereX = WorldX;

	int x, y, X_Overlap=32, Y_Overlap=15;
	for(y = 0; y < 35; y++)
	{   
		for(x = 0; x < 25; x++)   
		{	
		
			// Set the Foreground Pos

			tile_texfg.x = x+2*X_Overlap*x+(X_Overlap)*(y&1);   // ScreenX;

			tile_texfg.y = y+Y_Overlap*y;
			tile_texfg.curr_frame = level->Map[2][WhereX][WhereY].TileID; // Last Layer ( Foreground )

				
			
				tile_texfg.Draw_Graphics( );
			
			WhereX++;

		}
		WhereY++;

		WhereX = WorldX;
	}

  
With this the this method all Tile were draw correct. Scrolling to X is correct but when i am scrolling Y the tile are not drawing correctly. Is there a better method to draw like Tanstaafl''s Staggered Map Iso? Then i am using his MouseMap method ( Really Great! )
  
void pointer_get_map_coords( int CoordX, int CoordY, int *mapx, int *mapy )
{
	/*
	int x, y;
   // get the x and y positions on screen relative to scroll and center coords
	x = (CoordX + world.WorldX)/64;
	y = (CoordY + world.WorldY)/64;

   // store the results
   *mapx = x;
   *mapy = y;

  */

	int RegionX =((CoordX)/64);
	int RegionY =((CoordY)/32)*2; // The multiplying by two is very important


	int MouseMapX = CoordX % 64;
	int MouseMapY = CoordY % 32;


	int RegionDX;
	int	RegionDY;

	lpddtileex->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL );
  
	// make a couple aliases to make code cleaner, so we don''t

	// have to cast

	int mempitch        = (int)ddsd.lPitch;
	USHORT *video_buffer = (USHORT *)ddsd.lpSurface;
    
	DWORD color = video_buffer[MouseMapX+MouseMapY*(mempitch>>1)];

	lpddtileex->Unlock( NULL );


	if ( color == 63488 ) // Red ( Links Oben )

	{
		RegionDX = -1;
		RegionDY = -1;
	}
	if ( color == 65504 ) // Gelb ( Rechts Oben )

	{
		RegionDX = 0;
		RegionDY = -1;
	}
	if ( color == 65535 ) // White ( Tile )

	{
		RegionDX = 0;
		RegionDY = 0;
	}
	if ( color == 2016 ) // Green ( Links Unten )

	{
		RegionDX = -1;
		RegionDY = 1;
	}
	if ( color == 31 ) // Blue ( Rechts Unten )

	{
		RegionDX = 0;
		RegionDY = 1;

	}

	int result_x = RegionX + RegionDX;
	int result_y = RegionY + RegionDY;

	if ( result_x < 0 )
		result_x =0;
	if ( result_y < 0 )
		result_y =0;


	*mapx = result_x;
	*mapy = result_y;
}
  
this method works but how i can implement the feature when i am for Example at world.x = 15, world.y = 5; And then there is a problem with the X_ADJUST because i don`t know how i can implement it. Thanx Lutz Hören [ Power Productions ]
psYchOtroW

This topic is closed to new replies.

Advertisement