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


C++ PhysicalProperties::getHP方法代码示例

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


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

示例1: respondToCollision

void BalloonEscapeCollisionListener::respondToCollision(Game *game, Collision *collision)
{
	// NOTE FROM THE COLLIDABLE OBJECTS, WHICH ARE IN THE COLLISION,
	// WE CAN CHECK AND SEE ON WHICH SIDE THE COLLISION HAPPENED AND
	// CHANGE SOME APPROPRIATE STATE ACCORDINGLY
	GameStateManager *gsm = game->getGSM();
	AnimatedSprite *player = gsm->getSpriteManager()->getPlayer();
	PhysicalProperties *pp = player->getPhysicalProperties();
	//AnimatedSprite *bot = collision
	CollidableObject *sprite2 = collision->getCO2();
	PhysicalProperties *pp2 = sprite2->getPhysicalProperties();
	AnimatedSprite *bot = (AnimatedSprite*)sprite2;
	if (!collision->isCollisionWithTile() && player->getCurrentState() != L"DYING")
	{
		CollidableObject *sprite = collision->getCO1();

		if (sprite2->getPhysicalProperties()->getZ() == 1.0f) {
			
			bot = (AnimatedSprite*)sprite;
				 pp = sprite2->getPhysicalProperties();
					pp2 = sprite->getPhysicalProperties();

			sprite = collision->getCO2();
			sprite2 = collision->getCO1();
			if (sprite->getCollisionEdge() == BOTTOM_EDGE)
			{	
				bot->setCurrentState(L"DYING");
				pp2->setVelocity(0.0f, 0.0f);
				pp2->setAccelerationX(0);
				pp2->setAccelerationY(0);
				// ENEMY IS DEAD - WE SHOULD PLAY A DEATH ANIMATION
				// AND MARK IT FOR REMOVAL
			}
			else if (bot->getCurrentState() != L"DYING")
			{
				if (pp->getDelay() == 0) {
					if (pp->getHP() == 10 ) {
						//lives->setCurrentState(L"TWO");
						if(deadonce == true)
						//lives->setCurrentState(L"ONE");
						player->setCurrentState(L"DYING");
						pp->setDelay(90);
						pp->setVelocity(0.0f, 0.0f);
						pp->setAccelerationX(0);
						pp->setAccelerationY(0);
						deadonce=true;
					}
					else {
						pp->setDelay(90);
						pp->setHP(pp->getHP()-10);
						SpriteManager *spriteManager = gsm->getSpriteManager();
						AnimatedSpriteType *yellowman = spriteManager->getSpriteType(3);
						player->setSpriteType(yellowman);
					}
				}

				// PLAYER IS DEAD - WE SHOULD PLAY A DEATH ANIMATION
				// AND MARK IT FOR REMOVAL/RESPAWN/RESTART GAME, WHATEVER
				// THE DEMANDS OF THE GAME ARE
			}
		}
		else if(sprite->getPhysicalProperties()->getZ() == 1.0f) {
			PhysicalProperties *pp = sprite->getPhysicalProperties();
			if (sprite->getCollisionEdge() == BOTTOM_EDGE)
			{
				
				bot->setCurrentState(L"DYING");
				pp2->setVelocity(0.0f, 0.0f);
				pp2->setAccelerationX(0);
				pp2->setAccelerationY(0);
				// ENEMY IS DEAD - WE SHOULD PLAY A DEATH ANIMATION
				// AND MARK IT FOR REMOVAL

			}
			else if (bot->getCurrentState() != L"DYING")
			{
				if (pp->getDelay() == 0) {
					if (pp->getHP() == 10 ) {


						//lives->setCurrentState(L"TWO");
						if(deadonce == true)
						//lives->setCurrentState(L"ONE");
						player->setCurrentState(L"DYING");
						pp->setDelay(90);
						pp->setVelocity(0.0f, 0.0f);
						pp->setAccelerationX(0);
						pp->setAccelerationY(0);
						deadonce=true;

					}
					else {
						pp->setDelay(90);
						pp->setHP(pp->getHP()-10);
						SpriteManager *spriteManager = gsm->getSpriteManager();
						AnimatedSpriteType *yellowman = spriteManager->getSpriteType(3);
						player->setSpriteType(yellowman);
					}
				}

//.........这里部分代码省略.........
开发者ID:DavidLui,项目名称:-CSE380-Balloon-Escape,代码行数:101,代码来源:BalloonEscapeCollisionListener.cpp


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