当前位置: 首页>>代码示例>>C++>>正文


C++ Tile::Draw方法代码示例

本文整理汇总了C++中Tile::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Tile::Draw方法的具体用法?C++ Tile::Draw怎么用?C++ Tile::Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tile的用法示例。


在下文中一共展示了Tile::Draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RenderFrame

void Engine::RenderFrame()
{

	int cameraXOffset = camera->GetPosition().x, cameraYOffset = camera->GetPosition().y;
	Tile* tile;
	window->Clear();	
	
	bound = camera->GetTileBounds(tileSize);

	int tmp = bound.GetHeight();
	

	tmp++;
	tmp--;

	for(int y = 0, tileY = bound.Top; y < bound.GetHeight(); y++, tileY++)
	{
		for(int x = 0, tileX = bound.Left; x < bound.GetWidth(); x++, tileX++)
		{
			tile = graph->getTile(tileX,tileY);
			tile->Draw( (x * tileSize) - cameraXOffset, (y * tileSize) - cameraYOffset, window);
		}
	}

	window->Display();
}
开发者ID:snakesplusplane,项目名称:F-STP,代码行数:26,代码来源:Engine.cpp

示例2: RenderFrame

void Engine::RenderFrame()
{	    
	Collision checker; //DELETE
	//Camera offsets
	int camOffsetX, camOffsetY;

	Tile* tile;
	window->clear();
	
	//Get the tile bounds we need to draw
	sf::IntRect bounds = camera->GetTileBounds(tileSize);

	//Figure out how much to offset each tile
	camOffsetX = camera->GetTileOffset(tileSize).x;
	camOffsetY = camera->GetTileOffset(tileSize).y;
	//Loop through and draw each tile
	//We're keeping track of two variables in each loop. How many tiles
	//we've drawn (x and y), and which tile on the map we're drawing (tileX
	//and tileY)
	player->ground = false;	
	for(int y = 0, tileY = bounds.top; y < bounds.height; y++, tileY++)
	{
		for(int x = 0, tileX = bounds.left; x < bounds.width; x++, tileX++)
		{
			tile = new Tile(TextureManager.GetTexture(0)); // background!
			tile->Draw((x * tileSize) - camOffsetX, (y * tileSize) - camOffsetY, window);
			//Get the tile	
			tile = currentLevel->GetTile(tileX, tileY);
			if(tile){
 				tile->Draw((x * tileSize) - camOffsetX, (y * tileSize) - camOffsetY, window);
				if(checker.RectCollide(sf::FloatRect((x * tileSize), (y * tileSize), tileSize, tileSize), sf::FloatRect((player->getPosition().left), (player->getPosition().top), tileSize, tileSize)) && tile->baseSprite.getTexture() == Tile(TextureManager.GetTexture(2)).baseSprite.getTexture()){
				player->ground = true;
				}				
			}
					
		}
	}
	
	player->Draw(camOffsetX, camOffsetY, window);
	window->display();
}
开发者ID:jstone05,项目名称:Snake-Game,代码行数:41,代码来源:Engine.cpp

示例3: Draw

void Level::Draw(bool actionMode, Vector2i camOffset, IntRect bounds, Vector2f camPos, RenderWindow* window)
{
	int camOffsetX = camOffset.x;
	int camOffsetY = camOffset.y;

	//Variables: X & Y - how many tiles drawn, TILEX & TILEY - which tile being drawn
	int x, y, tileX, tileY;

	Tile* tile;
	
	//Loop and draw each tile
	for (y = 0, tileY = bounds.top; y < bounds.height; y++, tileY++)
	{
		for (x = 0, tileX = bounds.left; x < bounds.width; x++, tileX++)
		{
			//make sure tile location is within map
			if (tileX < 0 || tileY < 0 || tileX >= map.size() || tileY >= map[0].size())
				continue;

			//get the tile being drawn
			tile = map[tileX][tileY];
			if(tile)
			{
				tile->Draw((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);

				if(selectedTile == tile)
				{
					DrawSelectBorder((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);
				}
				else if (targetedTile == tile)
				{
					DrawTargetBorder((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);
				}
				if(hoverTile == tile)
				{
					DrawHoverBorder((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);
				}
				if(actionMode && selectedTile && selectedTile->GetDomOccupant())
				{
					DrawMoveSprites((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, selectedTile->GetDomOccupant()->GetSpeed(), tile, window);
				}
				else if(actionMode)
				{
					DrawGridSprite((x * TILESIZE) - camOffsetX, (y * TILESIZE) - camOffsetY, window);
				}
			}
		}
	}

	//Loop and draw each tile's occupants; this requires its own loop so that tiles don't get
	//drawn over entities
	for (y = 0, tileY = bounds.top; y < bounds.height; y++, tileY++)
	{
		for (x = 0, tileX = bounds.left; x < bounds.width; x++, tileX++)
		{
			//make sure tile location is within map
			if (tileX < 0 || tileY < 0 || tileX >= map.size() || tileY >= map[0].size())
				continue;

			//get the tile whose occupants are to be drawn
			tile = map[tileX][tileY];
			if(tile)
			{
				tile->DrawOccupants(camPos.x, camPos.y, window);
			}
		}
	}
}
开发者ID:pixley,项目名称:2DExperiment,代码行数:68,代码来源:level.cpp


注:本文中的Tile::Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。