GLUTEngine& GLUTEngine::getInstance() { if( engine_instance == NULL ) { if( has_been_destroyed == true ) reborn(); else born(); } return *engine_instance; // return a reference: client code can't delete it }
void hero::update() { double offsetX = 0; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left) && getPosition().x > getSize().x / 2) offsetX -= VELOCITY; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) && getPosition().x < game::WIDTH - getSize().x / 2) offsetX += VELOCITY; double offsetY = 0; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && getPosition().y > getSize().y / 2) offsetY -= VELOCITY; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) && getPosition().y < game::LENGTH - getSize().y / 2) offsetY += VELOCITY; _sprite.move(offsetX, offsetY); if (_isdead && reborn()) init(); }
void Player::update(float deltaTime) { if(mIsAlive) { updateAcceleration(); updateAnimation(deltaTime); settledPosition(deltaTime); collosion(); if(mShieldTime <= 0) { tryShot(deltaTime); }else { mShieldTime -= deltaTime; } } if(!mIsAlive) { if(!mAnimationManager.isPlaying()) { mAnimationManager.reset(); mAnimationManager.setAnimation(AnimationID::PlayerAnimationStay); mAnimationManager.play(); mShieldTime = mMaxShieldTime; reborn(); } updateAnimation(deltaTime); collosion(); } }
void StreamSessionAdapter::SessionHolder::heal() const { reborn(); // if we don't know how to heal it just reborn it }