本文整理汇总了C++中Enemy::SetSpeed方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::SetSpeed方法的具体用法?C++ Enemy::SetSpeed怎么用?C++ Enemy::SetSpeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::SetSpeed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpawnBoss
void EnemySpawner:: SpawnBoss()
{
Enemy* lEnemy;
lEnemy = dynamic_cast<Enemy*>(_Game->Spawn(new Enemy(), _Game->_Settings->EnemyBossTexture, true, nullptr));
lEnemy->SetHealth(_Game->_Settings->EnemyBossHealth);
lEnemy->SetSpeed(_Game->_Settings->EnemyBossSpeed);
lEnemy->Activate();
lEnemy->SetText("");
}
示例2: SpawnEnemy
void EnemySpawner:: SpawnEnemy()
{
Enemy* lEnemy;
if (Wave == 1)
{
lEnemy = dynamic_cast<Enemy*>(_Game->Spawn(new Enemy(), _Game->_Settings->Enemy1Texture, true, nullptr));
lEnemy->SetHealth(_Game->_Settings->Enemy1Health);
lEnemy->SetSpeed(_Game->_Settings->Enemy1Speed);
lEnemy->SetSound(_Game->_Settings->EnemyDeathSound);
}
if (Wave >= 2)
{
lEnemy = dynamic_cast<Enemy*>(_Game->Spawn(new Enemy(), _Game->_Settings->Enemy2Texture, true, nullptr));
lEnemy->SetHealth(_Game->_Settings->Enemy2Health);
lEnemy->SetSpeed(_Game->_Settings->Enemy2Speed);
lEnemy->SetSound(_Game->_Settings->EnemyDeathSound);
}
lEnemy->Activate();
}
示例3: Entity
void Stage_Stage3::Init()
{
stageOverTimer = 0;
boatTimer = 0;
stageClearTimer = 0;
bulletCount = 0;
GameStateManager::GetSingleton().Init();
Entity *newEntity;
#pragma region Texture
TextureManager& tm = TextureManager::GetSingleton();
tm.Add(T_BACKGROUND_1);
tm.Add(T_BACKGROUND_2);
tm.Add(T_BACKGROUND_3);
tm.Add(T_BACKGROUND_4);
tm.Add(T_BACKGROUND_5);
tm.Add(T_ENEMY_1);
tm.Add(T_ENEMY_2);
tm.Add(T_ENEMY_3);
tm.Add(T_ENEMY_BOAT);
tm.Add(T_ENEMY_BOSS);
tm.Add(T_EXPLOSION);
tm.Add(T_EXPLOSION_BIG);
tm.Add(T_PLAYER);
tm.Add(T_PLAYER_BOAT);
tm.Add(T_PLAYER_ADDON);
tm.Add(T_BULLET);
tm.Add(T_BOAT_BULLET);
tm.Add(T_BULLET_2);
tm.Add(T_BULLET2_EXPLOSION);
tm.Add(T_BULLET_SHELL);
tm.Add(T_BULLET_EXPLOSION);
tm.Add(T_UI_BACKGROUND_1);
tm.Add(T_UI_BACKGROUND_2);
tm.Add(T_UI_BAR_HEALTH);
tm.Add(T_UI_BAR_EXP);
tm.Add(T_UI_SHOP_POWER);
tm.Add(T_UI_SHOP_MORESPEED);
tm.Add(T_UI_SHOP_SPEED);
tm.Add(T_UI_SHOP_ADDON);
tm.Add(T_UI_SHOP_WEAPON);
tm.Add(T_UI_BAR_BOSS);
tm.Add(T_UI_GAMEOVER);
tm.Add(T_UI_BAR_BOSS_BG);
tm.Add(T_UI_BAR_BOSS_BG_BLACK);
tm.Add(T_UI_CLEAR);
tm.Add(T_DOKDO);
tm.Add(T_HP);
tm.Init();
#pragma endregion Texture
#pragma region Background
newEntity = new Entity(T_BACKGROUND_1, 800, 600);
newEntity->SetPos(0, 0);
entities.push_back(newEntity);
newEntity = new Entity(T_DOKDO, 454, 209);
newEntity->SetPos(200, 300);
newEntity->Params["Name"] = "Dokdo";
newEntity->SetSpeed(-30, 0, 0, 0);
entities.push_back(newEntity);
newEntity = new Entity(T_BACKGROUND_2, 1600, 600);
newEntity->SetPos(0, 0);
newEntity->Params["Type"] = "ScrollingBackground";
newEntity->SetSpeed(-150, 0, 0, 0);
entities.push_back(newEntity);
newEntity = new Entity(T_BACKGROUND_3, 1600, 600);
newEntity->SetPos(0, 0);
newEntity->Params["Type"] = "ScrollingBackground";
newEntity->SetSpeed(-200, 0, 0, 0);
entities.push_back(newEntity);
newEntity = new Entity(T_BACKGROUND_4, 1600, 600);
newEntity->SetPos(0, 0);
newEntity->Params["Type"] = "ScrollingBackground";
newEntity->SetSpeed(-250, 0, 0, 0);
entities.push_back(newEntity);
newEntity = new Entity(T_BACKGROUND_5, 1600, 600);
newEntity->SetPos(0, 0);
newEntity->Params["Type"] = "ScrollingBackground";
newEntity->SetSpeed(-300, 0, 0, 0);
entities.push_back(newEntity);
#pragma endregion Background
#pragma region Player
AddNewPlayer();
AddNewPlayerBoat();
Animation *newAddon = new Animation(T_PLAYER_ADDON, 150, 17, 1, 6);
newAddon->Params["Type"] = "PlayerAddon";
newAddon->Params["Name"] = "AddonUpper";
newAddon->Play(30.0f, true);
entities.push_back(newAddon);
newAddon = new Animation(T_PLAYER_ADDON, 150, 17, 1, 6);
newAddon->Params["Type"] = "PlayerAddon";
newAddon->Params["Name"] = "AddonLower";
newAddon->Play(30.0f, true);
entities.push_back(newAddon);
//.........这里部分代码省略.........
示例4: if
void Stage_Stage3::Update(float deltaTime)
{
SoundManager::GetSingleton().PlayLoop("BGM3");
NpcManager& npcManager = NpcManager::GetSingleton();
GameStateManager& gameState = GameStateManager::GetSingleton();
KeyboardManager& keyboard = KeyboardManager::GetSingleton();
if ( gameState.State["Level"] == 3 || gameState.State["Level"] == 6 || gameState.State["Level"] == 12 || gameState.State["Level"] == 15 )
{
gameState.State["AirPanic"] = 1;
}
else
{
gameState.State["AirPanic"] = 0;
}
if ( boatTimer <= 0 && !gameState.State["AirPanic"] && !entities.empty() )
{
boatTimer = 450;
Enemy *newEnemy = new Enemy(T_ENEMY_BOAT, 100, 36, 1, 1);
newEnemy->SetPos(800, 420);
newEnemy->SetSpeed(-100, 0, 0, 0);
newEnemy->Health = 100;
newEnemy->Params["Name"] = "EnemyPlane";
newEnemy->Params["EnemyType"] = "1";
newEnemy->Params["Collide"] = "Player";
newEnemy->AutoRemove = true;
entities.push_back(newEnemy);
}
else
{
boatTimer -= deltaTime;
}
if ( keyboard.IsKeyPressedN(VK_SPACE) )
{
gameState.State["PlayerMode"] = !gameState.State["PlayerMode"];
}
if ( keyboard.IsKeyPressedN(VK_ESCAPE) )
{
StageManager::GetSingleton().NextStage = "Menu";
}
#pragma region Debug Keys
else if ( keyboard.IsKeyPressedN(VK_F1) )
{
gameState.State["Exp"] = gameState.State["NextExp"];
}
else if ( keyboard.IsKeyPressedN(VK_F2) )
{
gameState.State["Score"]+=100000;
}
#pragma endregion Debug Keys
#pragma region Shop System
if ( keyboard.IsKeyPressedN('1') && gameState.State["Score"] >= gameState.State["Shop_Power"] && gameState.State["Power"] != 1)
{
gameState.State["Score"] -= gameState.State["Shop_Power"];
gameState.State["Power"]++;
}
else if ( keyboard.IsKeyPressedN('2') && gameState.State["Score"] >= gameState.State["Shop_Speed"] )
{
gameState.State["Score"] -= gameState.State["Shop_Speed"];
gameState.State["Speed"]++;
}
else if ( keyboard.IsKeyPressedN('3') && gameState.State["Score"] >= gameState.State["Shop_MoreSpeed"] )
{
gameState.State["Score"] -= gameState.State["Shop_MoreSpeed"];
gameState.State["Speed"] += 5;
}
else if ( keyboard.IsKeyPressedN('4') && gameState.State["Score"] >= gameState.State["Shop_Addon"] && gameState.State["Addon"] != 2 )
{
gameState.State["Score"] -= gameState.State["Shop_Addon"];
gameState.State["Addon"]++;
}
else if ( keyboard.IsKeyPressedN('5') && gameState.State["Score"] >= gameState.State["Shop_Weapon"] && gameState.State["Weapon"] != 1 )
{
gameState.State["Score"] -= gameState.State["Shop_Weapon"];
gameState.State["Power"] = 0;
gameState.State["Weapon"]++;
}
#pragma endregion Shop System
#pragma region Solid State Squad
if ( gameState.State["Clear"] == 1 )
{
stageClearTimer += deltaTime;
NpcManager::GetSingleton().RespawnTime = 99999;
if ( stageClearTimer > 5 )
StageManager::GetSingleton().NextStage = "Ending";
}
if ( gameState.State["GameOver"] == 1 )
{
stageOverTimer += deltaTime;
NpcManager::GetSingleton().RespawnTime = 99999;
if ( stageOverTimer > 5 )
keyboard.Update(VK_ESCAPE, true);
}
if ( gameState.State["1up"] == 1 )
{
Enemy *newEnemy;
//.........这里部分代码省略.........
示例5: Update
//.........这里部分代码省略.........
ships_.push_back(ship);
}
for (vector<Enemy*>::iterator it = enemyList.begin(); it != enemyList.end(); ++it)
{
int id, hp;
bool active;
Enemy::ENEMY_TYPE type;
float x, y, vel_x, vel_y, speed;
bs.Read(id);
bs.Read(active);
bs.Read(type);
bs.Read(x);
bs.Read(y);
bs.Read(vel_x);
bs.Read(vel_y);
bs.Read(speed);
bs.Read(hp);
Enemy* e = FindEnemyByID(id);
if (e)
{
float w = CalcW(Vector2(vel_x, vel_y));
/*if (speed != 0)
{
w = acosf(vel_x / speed);
}
else
{
w = 0.f;
}*/
e->Init(type, x, y, w, active);
e->SetVelocityX(vel_x);
e->SetVelocityY(vel_y);
e->SetSpeed(speed);
e->SetHP(hp);
}
}
// Base hp
bs.Read(base_hp);
SendInitialPosition();
}
break;
case ID_REJECT_PLAYER:
{
std::cout << "Rejected player" << std::endl;
return true;
}
break;
case ID_NEWSHIP:
{
unsigned int id;
bs.Read(id);
if( id == ships_.at(0)->GetID() )
{
// if it is me
break;
}
else
{
float x_, y_;
int type_;
std::string temp;