void CLogicBall::SetBallState( BALL_STATE eState, SVector vecInitPos, SVector vecInitVel, float fTimeElapsed) { m_ePreState = m_eCurState; m_eCurState = eState; if( eState == STATE_USEBALL_SHOOT ) { m_pShootSolution->SetStartPosition( vecInitPos ); m_fTimeElapsed = fTimeElapsed; SetStartVelocity(vecInitVel); m_f3SecondElap = 0.0f; } else if( eState == STATE_LOSEBALL ) { SetStartPos(vecInitPos); SetStartVelocity(vecInitVel); m_fTimeElapsed = fTimeElapsed; m_f3SecondElap = 0.0f; /* CInterfaceLayer *pInterfaceLayer_Game = m_pGSystem->GetResourceSys()->GetInterfaceLayer(FACTORY_ID_INTERFACELAYER_GAME); B_COM_INIT(); int nAdd = -1; B_COM_ADD_VALUE(nAdd); B_COM_SEND(pInterfaceLayer_Game, CInterfaceLayer_Game::Com_BallerID); */ } }
void CProjectile::initiateDestruction() { float fCurrentDir = (myVelocity.x / abs(myVelocity.x)) * -1.0f; m_bDead = true; SetStartVelocity(25.0f * fCurrentDir, 0.0f); m_visual.SetCurrentAnimation(P_ANIM_DEATH); }
void CLogicBall::SetState_LoseBall(SVector vecInitPos, SVector vecInitVel, float fTimeElapsed) { m_eCurState = STATE_LOSEBALL; SetStartPos(vecInitPos); SetStartVelocity(vecInitVel); m_fTimeElapsed = fTimeElapsed; }
void CProjectile::init(float _x, float _y, int _parentID, bool _salve) { ci_projectile_data = new CProjectileData(); std::string sProjectileSound; sProjectileSound = ci_projectile_data->getSound(_parentID); if(!_salve) { sProjectileSound += ".wav"; PlaySound(glDataBox->GetSoundBuffer(sProjectileSound), _parentID + 4); // Make sure sounds get played on different layers } else { sProjectileSound += "_salve.wav"; PlaySound(glDataBox->GetSoundBuffer(sProjectileSound), _parentID + 4); } m_fStartX = _x; m_fStartY = _y; m_iParent = _parentID; m_bSalve = _salve; setBlocked(-1); setScale(-1.0f, 1.0f); setPosition(_x, _y); setOrigin(ci_projectile_data->getOrigin(m_iParent).x, ci_projectile_data->getOrigin(m_iParent).y); m_collision = new pwCollisionRect(); m_collision->SetSize((float)ci_projectile_data->getSize(m_iParent).width, (float)ci_projectile_data->getSize(m_iParent).height); AddCollisionObject(ID_CO_PROJECTILE, m_collision); SetGravityMultiplier(ci_projectile_data->getGravity(m_iParent) * (CBeatSystem::GetBPM() * 1.5f) / 80.0f); // Use BMP to modify gravity to a certain extent -> projectile needs to hit coloss m_visual.SetFramesPerSecond(ci_projectile_data->getAnimationSpeed(m_iParent)); velocity temp = calculateForce(m_iParent); SetStartVelocity(temp.xVel, temp.yVel); m_visual.setTexture(*glDataBox->GetTexture(ci_projectile_data->getTexture(m_iParent))); m_visual.SetFrameSize(ci_projectile_data->getSize(m_iParent).width, ci_projectile_data->getSize(m_iParent).height); m_visual.SetTotalFrames(ci_projectile_data->getFrames(m_iParent)); m_visual.AddAnimation(P_ANIM_NORMAL, ci_projectile_data->getAnimation(m_iParent).normalStart, ci_projectile_data->getAnimation(m_iParent).normalEnd); m_visual.AddAnimation(P_ANIM_DEATH, ci_projectile_data->getAnimation(m_iParent).deathStart, ci_projectile_data->getAnimation(m_iParent).deathEnd); m_visual.SetCurrentAnimation(P_ANIM_NORMAL); AddDrawableObject(ID_DO_PROJECTILE, &m_visual); m_vProjectiles.push_back(this); glLogics->RegisterGameObject(this, ID_GS_PLAY); }
void CProjectile::bounceOrDestroy() { float fRandom = (float)(rand() % 10001); // 0 - 10000 fRandom /= 100.0f; // float between 0 - 100 if(!getBounced() && fRandom < ci_projectile_data->getBounceChance(m_iParent)) { if(CLevelData::getCurrentLevelString() == "darkage") { SetStartVelocity(100.0f, myVelocity.y); } else if(CLevelData::getCurrentLevelString() == "future") { SetStartVelocity(300.0f, myVelocity.y); } setBounced(true); } else { initiateDestruction(); } }