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


C++ Case::getTerrain方法代码示例

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


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

示例1: affiche

void Case::affiche(sf::RenderWindow& app)
{
    app.draw(getTerrain());

    if (true)
    {
        sf::Sprite corner(*m_texture);

        sf::IntRect r(Case::WIDTH, Case::HEIGHT, Case::WIDTH/2, Case::HEIGHT/2);
        corner.setTextureRect(r);

        Case* ctop = m_map.getCaseAt(m_intpos.x, m_intpos.y-1);
        Case* cbottom = m_map.getCaseAt(m_intpos.x, m_intpos.y+1);
        Case* cleft = m_map.getCaseAt(m_intpos.x-1, m_intpos.y);
        Case* cright = m_map.getCaseAt(m_intpos.x+1, m_intpos.y);
        Case* ctopleft = m_map.getCaseAt(m_intpos.x-1, m_intpos.y-1);
        Case* ctopright = m_map.getCaseAt(m_intpos.x+1, m_intpos.y-1);
        Case* cbottomleft = m_map.getCaseAt(m_intpos.x-1, m_intpos.y+1);
        Case* cbottomright = m_map.getCaseAt(m_intpos.x+1, m_intpos.y+1);

        std::string top = ctop? ctop->getTerrainName() : "";
        std::string bottom = cbottom? cbottom->getTerrainName() : "";
        std::string left = cleft? cleft->getTerrainName() : "";
        std::string right = cright? cright->getTerrainName() : "";

        if (top != "" && top != m_terrainName && top == left && (!ctopleft || ctopleft->getTerrainName() != m_terrainName))
        {
            r.left = ctop->getTerrain().getTextureRect().left;
            r.top = ctop->getTerrain().getTextureRect().top + Case::HEIGHT;

            corner.setPosition(m_pos.x + Case::WIDTH/4, m_pos.y);

            corner.setTextureRect(r);
            app.draw(corner);
        }

        if (top != "" && top != m_terrainName && top == right && (!ctopright || ctopright->getTerrainName() != m_terrainName))
        {
            r.left = ctop->getTerrain().getTextureRect().left + Case::WIDTH/2;
            r.top = ctop->getTerrain().getTextureRect().top + Case::HEIGHT;

            corner.setPosition(m_pos.x + Case::WIDTH/2, m_pos.y + Case::HEIGHT/4);

            corner.setTextureRect(r);
            app.draw(corner);
        }

        if (bottom != "" && bottom != m_terrainName && bottom == left && (!cbottomleft || cbottomleft->getTerrainName() != m_terrainName))
        {
            r.left = cbottom->getTerrain().getTextureRect().left;
            r.top = cbottom->getTerrain().getTextureRect().top + Case::HEIGHT + Case::HEIGHT/2;

            corner.setPosition(m_pos.x, m_pos.y + Case::HEIGHT/4);

            corner.setTextureRect(r);
            app.draw(corner);
        }

        if (bottom != "" && bottom != m_terrainName && bottom == right && (!cbottomright || cbottomright->getTerrainName() != m_terrainName))
        {
            r.left = cbottom->getTerrain().getTextureRect().left + Case::WIDTH/2;
            r.top = cbottom->getTerrain().getTextureRect().top + Case::HEIGHT + Case::HEIGHT/2;

            corner.setPosition(m_pos.x + Case::WIDTH/4, m_pos.y + Case::HEIGHT/2);

            corner.setTextureRect(r);
            app.draw(corner);
        }
    }

    if(hasObject())
    {
        if (!m_autoTile && !m_triggerable)
        {
            app.draw(getObjet());
        }
        else if (m_triggerable)
        {
            sf::IntRect r = m_objet.getTextureRect();
            sf::IntRect s = m_objet.getTextureRect();
            r.top += (m_triggered)? 0 : Case::HEIGHT;
            m_objet.setTextureRect(r);
            app.draw(m_objet);
            m_objet.setTextureRect(s);
        }
        else if (m_autoTile)
        {
            sf::Sprite plop(*m_texture);


            sf::IntRect r = m_objet.getTextureRect();
            r.left += Case::WIDTH/2;
            r.top += Case::HEIGHT/2;
            r.width = Case::WIDTH/2;
            r.height = Case::HEIGHT/2;

            sf::Vector2i& pos = m_pos;

            bool test = true;

//.........这里部分代码省略.........
开发者ID:hu9o,项目名称:gamedev,代码行数:101,代码来源:Case.cpp


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