コード例 #1
0
ファイル: BacteroidsState.cpp プロジェクト: duudel/bacteroids
 void BacteroidsState::PlayerCollision(Player *me, GameObject *obj, const vec2f &objToMe, float dist)
 {
     if (obj->GetType() == Bacter::TYPE)
     {
         vec2f v = objToMe.SafeNormalized() * dist/8.0f;
         vec2f p = me->GetPosition();
         me->AddVelocity(v);
         me->SetPosition(p + (v / 2.0f));
         me->TakeHit(m_soundPlayer);
         m_damageFade.Activate(1.0f);
         if (me->IsDead())
         {
             m_damageFade.SetFadeAcceleration(0.0f);
             m_damageFade.Activate(1.0f);
             m_soundPlayer.PlayPlayerDeathSound(p.x, p.y);
         }
     }
 }
コード例 #2
0
ファイル: BacteroidsState.cpp プロジェクト: duudel/bacteroids
 void BacteroidsState::BacterCollision(Bacter *me, GameObject *obj, const vec2f &objToMe, float dist)
 {
     if (obj->GetType() == Bacter::TYPE || obj->GetType() == Player::TYPE)
     {
         vec2f v = objToMe.SafeNormalized() * dist/8.0f;
         vec2f p = me->GetPosition();
         me->AddVelocity(v);
         me->SetPosition(p + (v / 2.0f));
         float r = me->GetRadius() + obj->GetRadius();
         me->ModifySize(1.0f + dist / r);
     }
     else if (obj->GetType() == Projectile::TYPE)
     {
         if (me->CanSplit())
         {
             m_score += me->GetPoints();
             m_kills++;
             me->AddVelocity(obj->GetVelocity() * 0.5f);
             SplitBacter(me);
         }
     }
 }