Ejemplo n.º 1
0
// Draw all tiles, from start to end position
void TileManager::DrawAllTilesAt( 
	BaseEngine* pEngine, 
	SDL_Surface* pSurface, 
	int iMapXStart, int iMapYStart,
	int iMapXEnd, int iMapYEnd,
	int iStartPositionScreenX, int iStartPositionScreenY ) const
{
	for ( int iTX = iMapXStart ; iTX <= iMapXEnd ; iTX++ )
		for ( int iTY = iMapYStart ; iTY <= iMapYEnd ; iTY++ )
		{
			DrawTileAt( pEngine, pSurface, 
				iTX, iTY, 
				iStartPositionScreenX+GetTileWidth()*(iTX-iMapXStart),
				iStartPositionScreenY+GetTileHeight()*(iTY-iMapYStart) );
		}
}
Ejemplo n.º 2
0
// Draw all tiles, from start to end position
void TileManager::UpdateTileAt( 
	BaseEngine* pEngine, 
	int iMapX, int iMapY,
	int iNewTileValue,
	int iScreenLeftTilePosition, 
	int iScreenTopTilePosition )
{
	// Set the new Tile value
	SetValue( iMapX, iMapY, iNewTileValue );
	// Draw the tile to the background
	DrawTileAt( pEngine, pEngine->GetBackground(), 
		iMapX, iMapY,
		iScreenLeftTilePosition, iScreenTopTilePosition );
	// Copy the background to the foreground
	pEngine->CopyBackgroundPixels( 
		iScreenLeftTilePosition, iScreenTopTilePosition, 
		GetTileWidth(), GetTileHeight() );
}
// Draw all tiles, from start to end position
void TileManager::UpdateTileAt( 
	BaseEngine* pEngine, 
	int iMapX, int iMapY,
	int iNewTileValue,
	int iScreenLeftTilePosition, 
	int iScreenTopTilePosition )
{
	// Set the new Tile value
	SetValue( iMapX, iMapY, iNewTileValue );
	// Draw the tile to the background
	DrawTileAt( pEngine, pEngine->GetBackground(), 
		iMapX, iMapY,
		iScreenLeftTilePosition, iScreenTopTilePosition );
	// Copy the background to the foreground
	pEngine->CopyBackgroundPixels( 
		iScreenLeftTilePosition, iScreenTopTilePosition, 
		GetTileWidth(), GetTileHeight() );
	// Update the screen - so that it gets redrawn
	SDL_Rect* pRect = pEngine->GetNextUpdateRect();
	pRect->x = iScreenLeftTilePosition;
	pRect->y = iScreenTopTilePosition;
	pRect->h = GetTileHeight();
	pRect->w = GetTileWidth();
}