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


C++ Country::getCenterOffsetX方法代码示例

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


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

示例1: draw

void UIManager::draw(sf::RenderWindow* target)
{

    sf::Sprite mapSprite;
    // this->mapController->update();
    sf::Texture tex = this->mapController->getMapTexture();
    mapSprite.setTexture(tex);
    mapSprite.setPosition(xincrease,yincrease);

    target->draw(mapSprite);

	//draw the unit counts on the countries
	//we know where the origins are for the demo
	sf::Text unitCountText;
	unitCountText.setFont(this->textFont);
	unitCountText.setCharacterSize(34);
	unitCountText.setColor(sf::Color(192,186,232));
	unitCountText.setStyle(sf::Text::Bold);

    //draw unit counts on countries
	for (int c = 0; c < this->mapController->map->getContinents().size(); c++) {
		Continent* continent = this->mapController->map->getContinents()[c];

		for (int cu = 0; cu < continent->countries.size(); cu++) {
			Country* country = continent->countries[cu];

			int xPos = country->getXPosition() + xincrease + country->getCenterOffsetX();
			int yPos = country->getYPosition() + yincrease + country->getCenterOffsetY();

			unitCountText.setPosition(xPos, yPos);

			std::stringstream ss;
			ss << country->getUnits();
			unitCountText.setString(ss.str().c_str());

			target->draw(unitCountText);
		}
	}

    //draw ui information

    for(int i = 0; i < 2; i++) {
        sf::Color c = mapController->playerColours[i];

        if(turnController->activePlayer != i) {
            int sub = 100;
            c.r = (c.r-sub < 0) ? 0 : c.r-sub;
            c.g = (c.g-sub < 0) ? 0 : c.g-sub;
            c.b = (c.b-sub < 0) ? 0 : c.b-sub;
        }
        unitCountText.setColor(c);
        unitCountText.setCharacterSize(46);
        int x = (i*(900+xincrease)+xincrease/2-100);
        std::stringstream uistring;
        uistring << "Player " << i+1;
        unitCountText.setString(uistring.str().c_str());
        unitCountText.setPosition(x,yincrease);
        target->draw(unitCountText);

        unitCountText.setCharacterSize(33);
        unitCountText.setPosition(x,yincrease+80);
        std::stringstream incomestring;
        incomestring << "Income: " << shopController->getPlayerIncome(turnController->playerList[i]);


        unitCountText.setString(incomestring.str().c_str());

        target->draw(unitCountText);

        unitCountText.setPosition(x,yincrease+120);
        std::stringstream unitstream;
        if(turnController->playerList[i]->income == -1) {
            if ( turnController->activePlayer != i) {
                unitstream << "Stored Units: " << 0;

            } else {
                unitstream << "Stored Units: " << shopController->getPlayerIncome(turnController->playerList[i]);
            }
        } else {
            unitstream << "Stored Units: " << turnController->playerList[i]->income;
        }
        unitCountText.setString(unitstream.str().c_str());

        target->draw(unitCountText);
    }




}
开发者ID:noahspriggs,项目名称:seng330,代码行数:90,代码来源:uimanager.cpp


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