本文整理汇总了C++中Level::Map方法的典型用法代码示例。如果您正苦于以下问题:C++ Level::Map方法的具体用法?C++ Level::Map怎么用?C++ Level::Map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level::Map方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculatePosition
void Player::calculatePosition(const Level& level, const sf::Vector2u& texSize)
{
auto drawPos = level.Map().getCoords(position);
drawPos.x += (float)(level.getLevelX_() - ((int)texSize.x / 2)) + 32;
drawPos.y += (float)(level.getLevelY_() + 224 - ((int)texSize.y - 32));
sprite.setPosition(drawPos);
}
示例2: updateAI
void Player::updateAI(Level& level)
{
switch (playerStatus)
{
case PlayerStatus::Walk:
return;
default:
break;
}
auto plr = level.getCurrentPlayer();
if (plr != nullptr)
{
setWalkPath(level.Map().getPath(mapPosition, plr->MapPosition()));
}
}
示例3: updateWalk
void Player::updateWalk(Game& game, Level& level)
{
updateWalkPath(game, level.Map());
updateAnimation(game);
}
示例4: draw
void TilesetLevelLayer::draw(sf::RenderTexture& levelTexture,
const LevelLayerInfo& layerInfo, SpriteShaderCache& spriteCache,
sf::Shader* spriteShader, const Level& level,
bool drawLevelObjects, bool isAutomap) const
{
Sprite2 sprite;
TextureInfo ti;
sf::FloatRect tileRect;
if (layerInfo.visible == false ||
tiles == nullptr)
{
if (drawLevelObjects == false)
{
return;
}
}
const auto& map = level.Map();
PairInt32 mapPos;
for (mapPos.x = visibleStart.x; mapPos.x < visibleEnd.x; mapPos.x++)
{
for (mapPos.y = visibleStart.y; mapPos.y < visibleEnd.y; mapPos.y++)
{
uint8_t light = 255;
int16_t index;
if (map.isMapCoordValid(mapPos) == false)
{
if (isAutomap == false)
{
light = map.getDefaultLight();
}
index = outOfBoundsTile.getTileIndex(mapPos.x, mapPos.y);
}
else
{
if (isAutomap == false)
{
light = std::max(map[mapPos].getDefaultLight(), map[mapPos].getCurrentLight());
}
index = map[mapPos].getTileIndex(layerIdx);
if (drawLevelObjects == true)
{
for (const auto& drawObj : map[mapPos])
{
if (drawObj != nullptr)
{
auto objLight = std::max(drawObj->getLight(), light);
drawObj->draw(levelTexture, spriteShader, spriteCache, objLight);
}
}
if (tiles == nullptr ||
layerInfo.visible == false)
{
continue;
}
}
}
if (index < 0 || light == 0)
{
continue;
}
if (tiles->get((size_t)index, ti) == true)
{
auto drawPos = map.toDrawCoord(mapPos, layerInfo.blockWidth, layerInfo.blockHeight);
drawPos += ti.offset;
tileRect.left = drawPos.x;
tileRect.top = drawPos.y;
tileRect.width = (float)ti.textureRect.width;
tileRect.height = (float)ti.textureRect.height;
if (layerInfo.visibleRect.intersects(tileRect) == true)
{
sprite.setTexture(ti, true);
sprite.setPosition(drawPos);
sprite.draw(levelTexture, spriteShader, spriteCache, light);
}
}
}
}
// draw player direction in automap, if enabled (baseIndex >= 0)
if (isAutomap == true &&
layerInfo.visible == true &&
level.getAutomapPlayerDirectionBaseIndex() >= 0 &&
level.getCurrentPlayer() != nullptr &&
tiles != nullptr)
{
auto direction = (size_t)level.getCurrentPlayer()->getDirection();
auto index = (size_t)level.getAutomapPlayerDirectionBaseIndex() + direction;
if (direction < (size_t)PlayerDirection::All &&
tiles->get(index, ti) == true)
{
auto drawPos = level.getCurrentAutomapViewCenter();
drawPos.x -= (float)layerInfo.blockWidth;
drawPos.y -= (float)layerInfo.blockHeight;
drawPos += ti.offset;
tileRect.left = drawPos.x;
tileRect.top = drawPos.y;
tileRect.width = (float)ti.textureRect.width;
tileRect.height = (float)ti.textureRect.height;
//.........这里部分代码省略.........