//update related functions void PlayState::updatePlaying(float delta) { score_ += delta * 200; scoreText_.move(player_.getVelocity().x * delta, 0); if (score_ > highscore_) highscore_ = score_; highscoreText_.move(player_.getVelocity().x * delta, 0); bool found(false); for (int i(0); i < GameConstants::Gameplay::MAX_ANTIGRAV; ++i) { if (player_.getGlobalBounds().intersects(antiGravs_[i].getGlobalBounds())) { found = true; } } if (found) { gravity_ = -1; } else { gravity_ = 1; } player_.update(delta, map_.currentCol_, gravity_, startGame_); translateView(delta); if (map_.isTerrainCollision(player_.getGlobalBounds())) { gameplayState_ = DeathScreen; } if (player_.getPosition().x > GameConstants::Map::MAP_WIDTH * GameConstants::Map::TILESIZE) { gameplayState_ = WinScreen; } //check for collisions with obstacles for (int i(0); i < obstacles_.size(); ++i) { obstacles_[i].update(map_.currentCol_); if (obstacles_[i].getGlobalBounds().intersects(player_.getGlobalBounds())) gameplayState_ = DeathScreen; } }
void TwoDimensionalDisplayController::motion( int x, int y ) { if( m_left_drag ) { double dx = x - m_last_x; double dy = y - m_last_y; m_last_x = x; m_last_y = y; translateView( dx, dy ); } if( m_right_drag ) { double dx = x - m_last_x; double dy = y - m_last_y; m_last_x = x; m_last_y = y; zoomView( dx, dy ); } }