本文整理汇总了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) ;
}
}
}
示例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) ;
}
//.........这里部分代码省略.........
示例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) ;
}
}
}