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


C++ Entity::Display方法代码示例

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


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

示例1: DisplayShots

void DisplayShots(Entity *&pShots)
{
	Entity *pTrav = pShots ;
	Entity *pTemp ;
	Point ptPlayerUFL, ptPlayerLBR, ptShotUFL, ptShotLBR ;
	ptPlayerUFL = Player.ptLocation + Player.pModel->ptBBUpperFrontLeft ;
	ptPlayerLBR = Player.ptLocation + Player.pModel->ptBBLowerBackRight ;

	while (pTrav != 0)
	{
		ptShotUFL = pTrav->ptLocation + pTrav->pModel->ptBBLowerBackRight ;
		ptShotLBR = pTrav->ptLocation + pTrav->pModel->ptBBUpperFrontLeft ;
		if (pTrav->ptLocation.dX < 50 && pTrav->ptLocation.dX > -50 &&
			pTrav->ptLocation.dZ < 100 && pTrav->ptLocation.dZ > -100)
		{
			if (!bExplode && (
					(ptPlayerUFL < ptShotUFL && ptPlayerLBR > ptShotUFL) || 
					(ptPlayerUFL < ptShotLBR && ptPlayerLBR > ptShotLBR) ||
					(ptShotUFL < ptPlayerUFL && ptShotLBR > ptPlayerUFL) || 
					(ptShotUFL < ptPlayerLBR && ptShotLBR > ptPlayerLBR)))
			{
				bExplode = true ;
				iCount = 0 ;
			}
			pTrav->Display() ;
			if (!bPause) pTrav->ptLocation = pTrav->ptLocation + pTrav->ptDirection ;
			pTrav = pTrav->pNext ;
		} else 
		{
			pTemp = pTrav ;
			pTrav = pTrav->pNext ;
			pTemp->pModel = 0 ;
			RemoveEntity(pShots, pTemp) ;
		}
	}
}
开发者ID:yoiang,项目名称:Google-Code-Dump,代码行数:36,代码来源:Main.cpp

示例2: DisplayHandler

void DisplayHandler () // display callback function
{
	if (bRotate) 
	{
		fCameraAngle[0] += 1.0 ;
		fCameraAngle[2] += 1.0 ;
	}
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;
	glLoadIdentity() ;

	SetCamera() ;

	if (!bPause)
	{
		GLfloat fTempX = GLfloat(iLastMouseX) / GLfloat(iWinWidth) ;
		GLfloat fTempY = GLfloat(iLastMouseY) / GLfloat(iWinHeight) ;
		GLfloat fFixedX = (Player.ptLocation.dX - 8.65) / -17.3 ;
		GLfloat fFixedZ = (Player.ptLocation.dZ - 8.65) / -17.3 ;
		if (bRightMouseDown)
		{
			if (!(fFixedX + 0.02 > fTempX && fFixedX - 0.02 < fTempX))
			{
				if (fFixedX > fTempX)
				{
					Player.ptLocation.dX += 0.1 ;
					if (Player.ptAngle.dZ > -20) 
						Player.ptAngle.dZ -= 5.0 ;
				} else
				{
					Player.ptLocation.dX -= 0.1 ;
					if (Player.ptAngle.dZ < 20) 
						Player.ptAngle.dZ += 5.0 ;
				}
			} else
			{
				if (Player.ptAngle.dZ < 0) Player.ptAngle.dZ += 5.0 ;
				else if (Player.ptAngle.dZ > 0)	Player.ptAngle.dZ -= 5.0 ;
			}
			if (!(fFixedZ + 0.1 > fTempY && fFixedZ - 0.02 < fTempY))
			{
				if (fFixedZ > fTempY)
				{
					Player.ptLocation.dZ += 0.1 ;
				} else 
				{
					Player.ptLocation.dZ -= 0.1 ;
				}
			}
		} else Player.ptAngle.dZ = 0 ;

		if (randp() > 0.98) AddPlanet() ;
		AddStar() ;
		AddStar() ;
		AddStar() ;
		AddStar() ;
		AddStar() ;
		AddStar() ;

		if (/*!bExplode && */iCount % 15 == 0) SpawnEnemy() ;

		if (!bExplode && bAutofire && iCount % 4 == 0) FireShot(&Player, pPlayerShots) ;

		iCount ++ ;

	}
	
	DisplayStars() ;
	DisplayPlanets() ;
	DisplayEnemies() ;

	DisplayShots(pPlayerShots) ;
	DisplayShots(pEnemyShots) ;

	if (bExplode && !bPause)
	{
		if (iCount == 0) 
		{
			printf("Game over\n") ;
			MakeExplosion(Player.ptLocation, 1000) ;
		}
	} else 
	{
		if (iCount % 4)
		{
			Particle *pNew = new Particle ;
			pNew->ptLocation.dX = Player.ptLocation.dX + randp() * 0.5 - 0.25;
			pNew->ptLocation.dY = Player.ptLocation.dY + 0.3 * randp() ;
			pNew->ptLocation.dZ = Player.ptLocation.dZ - 1.5 + 0.2 * randp() ;
			pNew->ptVelocity.dX = 0 ;
			pNew->ptVelocity.dY = 0 ;
			pNew->ptVelocity.dZ = -0.2 ;
			pNew->ptColor.dX = 0.98 ;
			pNew->ptColor.dY = 0.59 + 0.3 * randp() - 0.15 ;
			pNew->ptColor.dZ = 0.01 ;
			pNew->dAlpha = 0.7 ;
			pNew->dMass = 1 ;
			pNew->dLife = 7 * randp() + 3 ;
			pNew->ptAcceleration = 0 ;
			Particles.AddBack(pNew) ;
		}
//.........这里部分代码省略.........
开发者ID:yoiang,项目名称:Google-Code-Dump,代码行数:101,代码来源:Main.cpp

示例3: DisplayEnemies

void DisplayEnemies()
{
	Entity *pTrav = pEnemys ;
	Entity *pTravShots ;
	Entity *pTemp ;
	bool bShot ;
	Point ptBBModelUFL, ptBBModelLBR, ptBBShotUFL, ptBBShotLBR ;
	while (pTrav != 0)
	{
		if (pTrav->ptLocation.dZ > -100)
		{
			ptBBModelUFL = pTrav->ptLocation + pTrav->pModel->ptBBUpperFrontLeft ;
			ptBBModelLBR = pTrav->ptLocation + pTrav->pModel->ptBBLowerBackRight ;

			bShot = false ;
			pTravShots = pPlayerShots ;
			while (pTravShots != 0)
			{
				ptBBShotUFL = pTravShots->ptLocation + pTravShots->pModel->ptBBUpperFrontLeft ;
				ptBBShotLBR = pTravShots->ptLocation + pTravShots->pModel->ptBBLowerBackRight ;

				if ((ptBBModelUFL < ptBBShotUFL && ptBBModelLBR > ptBBShotUFL) || 
					(ptBBModelUFL < ptBBShotLBR && ptBBModelLBR > ptBBShotLBR))
				{
					bShot = true ;

					MakeExplosion(pTrav->ptLocation, 500) ;

					if (!bExplode)
					{
						iScore += 100 ;
						printf ("Score: %i\n", iScore) ;
					}

					pTemp = pTrav ;
					pTrav = pTrav->pNext ;
					pTemp->pModel = 0 ;
					RemoveEntity(pEnemys, pTemp) ;
					pTravShots->pModel = 0 ;
					RemoveEntity(pPlayerShots, pTravShots) ;
					break ;
				}
				pTravShots = pTravShots->pNext ;
			}

			if (!bShot)
			{
				ptBBShotUFL = Player.ptLocation + Player.pModel->ptBBUpperFrontLeft ;
				ptBBShotLBR = Player.ptLocation + Player.pModel->ptBBLowerBackRight ;

				if (!bExplode && ((ptBBModelUFL < ptBBShotUFL && ptBBModelLBR > ptBBShotUFL) || 
									(ptBBModelUFL < ptBBShotLBR && ptBBModelLBR > ptBBShotLBR)))
				{
					bExplode = true ;
					iCount = 0 ; 

					MakeExplosion(pTrav->ptLocation, 500) ;
					pTemp = pTrav ;
					pTrav = pTrav->pNext ;
					pTemp->pModel = 0 ;
					RemoveEntity(pEnemys, pTemp) ;
				} else
				{
//					if (randp() > 0.99)
					if (!bExplode && randp() > 0.99)
						FireShot(pTrav, pEnemyShots) ;
					pTrav->Display() ;
					if (!bPause) pTrav->ptLocation = pTrav->ptLocation + pTrav->ptDirection ;
					pTrav = pTrav->pNext ;
				}
			}
		} else 
		{
			pTemp = pTrav ;
			pTrav = pTrav->pNext ;
			pTemp->pModel = 0 ;
			RemoveEntity(pEnemys, pTemp) ;
		}
	}
}
开发者ID:yoiang,项目名称:Google-Code-Dump,代码行数:80,代码来源:Main.cpp


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