本文整理汇总了C++中CGameObject::getOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameObject::getOrigin方法的具体用法?C++ CGameObject::getOrigin怎么用?C++ CGameObject::getOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameObject
的用法示例。
在下文中一共展示了CGameObject::getOrigin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testObjects
void
CScene::update(void)
{
objects_vec testObjects(m_Objects); // make a local copy of vector
bool explodeRock, explodeShip;
// Crappy collission detection for bullet-rock and ship-rock
while ( testObjects.size() > 0 ) {
explodeRock = false;
explodeShip = false;
CGameObject *obj = testObjects[0];
if ((obj->getType() == OBJECT_BULLET || obj == m_Ship) && obj->isDead() == false && obj->isInvulnerable() == false ) {
for (objects_vec::iterator it = m_Objects.begin(); it != m_Objects.end(); ++it) {
CGameObject *obj2 = *it;
if ( obj2->isDead() )
continue;
if (obj2->getType() != OBJECT_ROCK)
continue;
if ( obj->collission(obj2) ) {
CRock *rock = (CRock *) obj2; // Cast should be okey
if ( rock->isBig() ) {
#if USE_SOUND
PlaySound( "detpack.wav", NULL, NULL );
#endif
explodeRock = true;
if (obj->getType() == OBJECT_BULLET)
game->addPoints( 100 );
} else {
if (obj->getType() == OBJECT_BULLET)
game->addPoints( 25 );
}
// Remove old rock and object from the scene
rock->setDeathTime(-1);
obj->setDeathTime(-1);
m_NumRocks--;
if (obj->getType() == OBJECT_SHIP) {
game->loseLive();
explodeShip = true;
}
}
}
// Create the small rocks left after the explosion
if (explodeRock) {
for (int i=0; i < 4 + (rand()&1); i++) {
CRock *newRock = new CRock(false);
newRock->setOrigin( obj->getOrigin() );
newRock->setDeltaOrigin(D3DXVECTOR3((rand() % 100)/500.0f - 0.05f, (rand() % 100)/500.0f - 0.05f, 0.0f));
newRock->setDeltaRotation(D3DXVECTOR3(0.0f, 0.0f, (rand() % 100)/500.0f - 0.05f));
m_Objects.push_back( newRock );
m_NumRocks++;
}
}
if (explodeShip) {
// Some shatters from the ship
for (int i=0; i < 4 + (rand()%4); i++) {
CSpaceShip *particle = new CSpaceShip();
particle->setOrigin( m_Ship->getOrigin() );
particle->setSize(D3DXVECTOR3(0.02f * (1+rand()%4) / 2.0f, 0.02f * (1+rand()%4) / 2.0f, 0.02f * (rand()%4) / 2.0f));
particle->setDeltaOrigin(D3DXVECTOR3((1+rand() % 100)/500.0f - 0.1f, (1+rand() % 100)/500.0f - 0.1f, 0.0f));
particle->setDeltaRotation(D3DXVECTOR3(0.0f, 0.0f, (1+rand() % 100)/500.0f - 0.025f));
particle->setDecayRotation(1.0f);
particle->setDeathTime( 1500 );
m_Objects.push_back( particle );
}
// Some bullets for extra effect
for (int i=0; i < 4 + (rand()%4); i++) {
CBullet *particle = new CBullet();
particle->setOrigin( m_Ship->getOrigin() );
particle->setSize(D3DXVECTOR3(0.02f * (1+rand()%4) / 2.0f, 0.02f * (1+rand()%4) / 2.0f, 0.02f * (1+rand()%4) / 2.0f));
particle->setDeltaOrigin(D3DXVECTOR3((1+rand() % 100)/250.0f - 0.02f, (1+rand() % 100)/250.0f - 0.02f, 0.0f));
//particle->setDeltaRotation(D3DXVECTOR3(0.0f, 0.0f, (rand() % 100)/500.0f - 0.025f));
//particle->setDecayRotation(1.0f);
particle->setDeathTime( 500 );
m_Objects.push_back( particle );
}
}
}
testObjects.erase( testObjects.begin() );
}
// Call update on objects
for (objects_vec::iterator it = m_Objects.begin(); it != m_Objects.end(); ++it) {
CGameObject *obj = *it;
if ( obj->isDead() ) {
// FIXME:
// Should remove from list, skip for now
continue;
}
obj->update();
}
//.........这里部分代码省略.........