void SpaceShip::takeAHit(double damage) { hull -= damage; // cout << "Took hit, hull is now : " << hull << endl; // temp test if (hull <= 0) { hull = 0; blowUp(); } }
void PufferFish::update(){ float timeDiff = (SDL_GetTicks() - birthTime) / 100.0f; position.setY(spawnY + sin(timeDiff) * Game::getTheInstance()->getDeltaTime() * 100); if (health < 3){ // 3 = max health blowUp(); } if (dying){ currentFrame = 0; dead = true; Game::getTheInstance()->setCurrentLevel(2); // we've finished the level, lets go to the next one } }
void CScreamer::checkSecondarySkill(unsigned int msecs) { // Si la habilidad secundaria está siendo usada if(_secondarySkillIsActive) { // Comprobamos si tenemos que explotar, ya que podrían habernos // disparado al escudo if(_currentScreamerShield < 0) { // El screamer explota blowUp(); } else { // Reducir la energia si es posible if(_currentScreamerShield > 1) { // Decrementar iterativamente hasta llegar a 0 // o no poder decrementar mas _screamerShieldDamageTimer += msecs; unsigned int steps = _screamerShieldDamageTimer / _screamerShieldDamageTimeStep; _screamerShieldDamageTimer = _screamerShieldDamageTimer % _screamerShieldDamageTimeStep; for(int i = 0; i < steps; ++i) { _currentScreamerShield -= _screamerShieldDamageTimeStep; if(_currentScreamerShield <= 1) { _currentScreamerShield = 1; break; } } } } } else if(_currentScreamerShield < _screamerShieldThreshold) { // Incremento el timer de recuperación hasta llegar al máximo _screamerShieldRecoveryTimer += msecs; unsigned int steps = _screamerShieldRecoveryTimer / _screamerShieldRecoveryTimeStep; _screamerShieldRecoveryTimer = _screamerShieldRecoveryTimer % _screamerShieldRecoveryTimeStep; for(int i = 0; i < steps; ++i) { _currentScreamerShield += _screamerShieldDamageTimeStep; if(_currentScreamerShield >= _screamerShieldThreshold) { _currentScreamerShield = _screamerShieldThreshold; break; } } } }
void PufferFish::playerCollide(){ blowUp(); if (blownUp){ CollisionHandler::getTheInstance()->getPlayer()->setHealth(0); } }