本文整理汇总了C++中EntityManager::getPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::getPlayer方法的具体用法?C++ EntityManager::getPlayer怎么用?C++ EntityManager::getPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::getPlayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DarkGDK
//.........这里部分代码省略.........
// Spawn a new enemy for testing
timeSinceLastSpawn += elapsedTime;
if( timeSinceLastSpawn > timeBetweenSpawns ) {
timeSinceLastSpawn = 0.0;
entityManager.spawnRandomWave();
/*
Enemy *enemy = new Enemy(Vector2D(100.0,-10.0));
// Set up a test path
Path *path = new Path();
path->addWaypoint( Vector2D(200.0,200.0) );
path->addWaypoint( Vector2D(400.0,300.0) );
path->addWaypoint( Vector2D(700.0,-10.0) );
path->setLooped(false);
enemy->setPath( path );
enemy->getStateMachine()->changeState( EnemyFollowPathThenDieState::getInstance() );
entityManager.registerEntity( enemy );
*/
}
// Update and draw the enemies
entityManager.updateAllEntities( elapsedTime );
entityManager.drawAllEntities();
// Reset the first entities position
if( dbMouseClick() == 2 ) {
Vector2D position( dbMouseX(), dbMouseY() );
Vector2D velocity( 0.0, -20.0 );
//Vector2D velocity = target - position;
//velocity.Normalize();
//velocity *= 20.0;
Bullet *bullet = new Bullet(position,velocity);
entityManager.registerEntity( bullet );
}
// Reset the enemies randomly if space pressed
if( dbSpaceKey() && spacePressedLastFrame == false ) {
spacePressedLastFrame = true;
Enemy *enemy = new Enemy();
enemy->setPosition(Vector2D(100.0,-30.0));
// Set up a test path
Path *path = new Path();
path->addWaypoint( Vector2D(200.0,200.0) );
path->addWaypoint( Vector2D(400.0,300.0) );
path->addWaypoint( Vector2D(700.0,-30.0) );
path->setLooped(false);
enemy->setPath( path );
enemy->getStateMachine()->changeState( EnemyFollowPathThenDieState::getInstance() );
entityManager.registerEntity( enemy );
}
if( !dbSpaceKey() )
spacePressedLastFrame = false;
// Update the target
if( dbMouseClick() == 1 ) {
target.x = dbMouseX();
target.y = dbMouseY();
}
// Draw the target
//DrawTarget( target );
// Put any debugging messages here
//sprintf( debugText, "Key code: %d", dbScanCode() ); // For finding keyboard scan codes
//sprintf( debugText, "Elapsed time: %f", elapsedTime );
//sprintf( debugText, "Entities: %d FPS: %d", entityManager.getSize(), dbScreenFPS() );
//sprintf( debugText, "%s", dbChecklistString (1) );
//sprintf( debugText, "JoystickY: %d", joystickY );
//sprintf( debugText, "FPS: %d", dbScreenFPS() );
sprintf( debugText, "Score: %d", entityManager.getPlayer()->getScore() );
//sprintf( debugText, "Player Position: %f,%f", entityManager.getPlayer()->getPosition().x, entityManager.getPlayer()->getPosition().y );
//sprintf( debugText, "VectorX: %f VectorY: %f", testVector.x, testVector.y );
//sprintf( debugText, "screenWidth: %d screenHeight: %d", dbScreenWidth(), dbScreenHeight() );
// Print out the debug text
dbInk( RGB(0,0,255), RGB(255,255,255) );
dbText( 0, SCREEN_HEIGHT-20, debugText );
// Draw scanlines
//drawScanlines(3);
// break out if escape has been pressed
if ( dbEscapeKey ( ) )
break;
// update the contents of the screen
dbSync ( );
}
// and now everything is ready to return back to Windows
return;
}
示例2: Execute
void EnemyCollideWithPlayerState::Execute(Enemy *enemy) {
enemy->getSteeringBehaviour()->setSeek(true, entityManager.getPlayer()->getPosition() );
}