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


C++ StaticObject::draw方法代码示例

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


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

示例1: StaticObject

void violet::HUD::drawInventory(Player* player) {
	int topBasePoint = m_videoManager->RegularText->getIndent()
			+ (m_videoManager->RegularText->getHeight()) * 4;

	VideoMode screen = m_videoManager->getVideoMode();
	const int barLeft = screen.Width / 25;
	const int barLen = screen.Width / 15;
	const int barHeight = m_videoManager->RegularText->getHeight() / 10;

	GLfloat bcolor[] = { 1.0f, 1.0f, 1.0f, 0.0f };
	GLfloat fcolor1[] = { 1.0f, 1.0f, 1.0f, 1.0f };
	GLfloat fcolor2[] = { 1.0f, 1.0f, 1.0f, 1.0f };

	const float baseScale = m_videoManager->Scale * 0.2;

	const int dataLeft = barLeft + 25 * m_videoManager->Scale;

	// TODO: cache weapon image inside this class
	StaticObject* wpnImg = new StaticObject(barLeft,
		m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight(),
		128, 128,
		player->getWeapon()->getDroppedTex(), false);
	wpnImg->Scale = baseScale;

	glDisable(GL_TEXTURE_2D);
	wpnImg->RMask = wpnImg->GMask = wpnImg->BMask = 1.0f;
	wpnImg->draw(false, false);
	glEnable(GL_TEXTURE_2D);
	wpnImg->RMask = wpnImg->GMask = wpnImg->BMask = 0;
	wpnImg->draw(false, false);

	delete wpnImg;

	std::ostringstream oss;
	oss << player->getWeapon()->Ammo << '/' << player->getWeapon()->AmmoClipSize;
	m_videoManager->RegularText->draw(oss.str(), dataLeft,
		m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight(),
		TextManager::LEFT, TextManager::MIDDLE);

	m_inventoryImg[0]->draw(false, false, barLeft,
		m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight() * 2,
		0.0f, baseScale);

	oss.str("");
	oss << player->Grenades;
	m_videoManager->RegularText->draw(oss.str(), dataLeft,
		m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight() * 2,
		TextManager::LEFT, TextManager::MIDDLE);

	m_inventoryImg[1]->draw(false, false, barLeft,
		m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight() * 3,
		0.0f, baseScale);

	oss.str("");
	oss << player->Teleports;
	m_videoManager->RegularText->draw(oss.str(), dataLeft,
		m_videoManager->RegularText->getIndent() + m_videoManager->RegularText->getHeight() * 3,
		TextManager::LEFT, TextManager::MIDDLE);

	int bonusN = 0;
	for (int i = PLAYER_BONUS_FIRST; i < PLAYER_BONUS_COUNT; i++) {
		if (player->bonusTimes[i] > 0) {
			const int y = topBasePoint + bonusN * 132 * baseScale;
			m_bonusImg[(PlayerBonusType) i]->draw(false, false, barLeft, y, 0,
					baseScale);
			drawBar(barLeft + 25 * m_videoManager->Scale, y, barLen, barHeight,
					player->bonusTimes[i] / 15000.0f, bcolor, fcolor1, fcolor2);
			bonusN++;
		}
	}
}
开发者ID:bla-rs,项目名称:Experimental,代码行数:71,代码来源:HUD.cpp


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