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


C++ AssetManager::GetExplosionCenter方法代码示例

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


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

示例1: GameObject

Explosion::Explosion(const AssetManager& assets, int xPosition, int yPosition, int power, std::list<GameObject*>& objects, const Map& map)
    : GameObject(Rectangle(xPosition, yPosition, 0, 0), 14),
      parts_()
{
    // Create the explosion parts.

    parts_.push_back(ExplosionPart(assets.GetExplosionCenter(), xPosition, yPosition, 14));

    // Each loop expands in one direction as long as not blocked and as long as the power is not exhausted.
    // Top
    bool block = false;
    for (int i = 1; (i <= power) && (block == false); ++i)
    {
        if (CanExplode(Rectangle(xPosition, yPosition - 48 * i, 48, 48), objects, map, block) == true)
        {
            AnimatedSprite* sprite = (i == power) ? assets.GetExplosionTopEnd() : assets.GetExplosionVertical(); // The final part has its own sprites.
            parts_.push_back(ExplosionPart(sprite, xPosition, yPosition - 48 * i, 14));
        }
    }
    // Right
    block = false;
    for (int i = 1; (i <= power) && (block == false); ++i)
    {
        if (CanExplode(Rectangle(xPosition + 48 * i, yPosition, 48, 48), objects, map, block) == true)
        {
            AnimatedSprite* sprite = (i == power) ? assets.GetExplosionRightEnd() : assets.GetExplosionHorizontal();
            parts_.push_back(ExplosionPart(sprite, xPosition + 48 * i, yPosition, 14));
        }
    }
    // Bottom
    block = false;
    for (int i = 1; (i <= power) && (block == false); ++i)
    {
        if (CanExplode(Rectangle(xPosition, yPosition + 48 * i, 48, 48), objects, map, block) == true)
        {
            AnimatedSprite* sprite = (i == power) ? assets.GetExplosionBottomEnd() : assets.GetExplosionVertical();
            parts_.push_back(ExplosionPart(sprite, xPosition, yPosition + 48 * i, 14));
        }
    }
    // Left
    block = false;
    for (int i = 1; (i <= power) && (block == false); ++i)
    {
        if (CanExplode(Rectangle(xPosition - 48 * i, yPosition, 48, 48), objects, map, block) == true)
        {
            AnimatedSprite* sprite = (i == power) ? assets.GetExplosionLeftEnd() : assets.GetExplosionHorizontal();
            parts_.push_back(ExplosionPart(sprite, xPosition - 48 * i, yPosition, 14));
        }
    }
}
开发者ID:BenjaminHamon,项目名称:ClassicBomberman,代码行数:50,代码来源:Explosion.cpp


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