void HexagonGame::incrementDifficulty() { playSound("levelUp.ogg"); setRotationSpeed(levelData.getRotationSpeed() + levelData.getRotationSpeedIncrement() * getSign(getRotationSpeed())); setRotationSpeed(levelData.getRotationSpeed() * -1); if(status.fastSpin < 0 && abs(getRotationSpeed()) > levelData.getValueFloat("rotation_speed_max")) setRotationSpeed(levelData.getValueFloat("rotation_speed_max") * getSign(getRotationSpeed())); status.fastSpin = levelData.getFastSpin(); }
void HexagonGame::update(float mFrameTime) { if(!hasDied) { manager.update(mFrameTime); updateLevelEvents(mFrameTime); if(timeStop <= 0) { currentTime += mFrameTime / 60.0f; incrementTime += mFrameTime / 60.0f; } else timeStop -= 1 * mFrameTime; updateIncrement(); updateLevel(mFrameTime); updateRadius(mFrameTime); if(!getBlackAndWhite()) styleData.update(mFrameTime); } else setRotationSpeed(getRotationSpeed() / 1.001f); updateKeys(); if(!getNoRotation()) updateRotation(mFrameTime); if(mustRestart) newGame(levelData.getId(), false); }
void Jets::update(Uint32 ticks) { int deviation = getRandomFactorBetween(0,200); int length = sqrt((playerX+deviation - X())*(playerX+deviation-X()) + (playerY+deviation-Y())*(playerY+deviation-Y())); velocityX(throttleX*(playerX - X())/length); velocityY(throttleY*(playerY - Y())/length); int delta_x = playerX - X(); int delta_y = playerY - Y(); angle = -(atan2(delta_y, delta_x)*180.0000)/3.142 ; Vector2f incr = getVelocity() * static_cast<float>(ticks) * 0.001; setPosition(getPosition() + incr); if(getRotate()) angle += getRotationSpeed() % 360; if ( Y() < 0) { velocityY( abs( velocityY() ) ); } if ( Y() > worldHeight-frameHeight) { velocityY( -abs( velocityY() ) ); } if ( X() < 0) { velocityX( abs( velocityX() ) ); } if ( X() > worldWidth-frameWidth) { velocityX( -abs( velocityX() ) ); } }
//----------------------------------------------------------------------- void VortexAffector::copyAttributesTo (ParticleAffector* affector) { ParticleAffector::copyAttributesTo(affector); VortexAffector* vortexAffector = static_cast<VortexAffector*>(affector); vortexAffector->mRotation = mRotation; vortexAffector->mRotationVector = mRotationVector; vortexAffector->setRotationSpeed(mDynamicAttributeFactory.cloneDynamicAttribute(getRotationSpeed())); }
//----------------------------------------------------------------------- void TextureRotator::copyAttributesTo (ParticleAffector* affector) { ParticleAffector::copyAttributesTo(affector); TextureRotator* textureRotator = static_cast<TextureRotator*>(affector); textureRotator->setRotation(mDynamicAttributeFactory.cloneDynamicAttribute(getRotation())); textureRotator->setRotationSpeed(mDynamicAttributeFactory.cloneDynamicAttribute(getRotationSpeed())); textureRotator->mUseOwnRotationSpeed = mUseOwnRotationSpeed; }
void PUVortexAffector::copyAttributesTo( PUAffector* affector ) { PUAffector::copyAttributesTo(affector); PUVortexAffector* vortexAffector = static_cast<PUVortexAffector*>(affector); vortexAffector->_rotation = _rotation; vortexAffector->_rotationVector = _rotationVector; vortexAffector->setRotationSpeed(getRotationSpeed()->clone()); }
void PUGeometryRotator::copyAttributesTo( PUAffector* affector ) { PUAffector::copyAttributesTo(affector); PUGeometryRotator* geometryRotator = static_cast<PUGeometryRotator*>(affector); geometryRotator->setRotationSpeed(getRotationSpeed()->clone()); geometryRotator->_useOwnRotationSpeed = _useOwnRotationSpeed; geometryRotator->_rotationAxis = _rotationAxis; geometryRotator->_rotationAxisSet = _rotationAxisSet; }
void HexagonGame::updateRotation(float mFT) { auto nextRotation(getRotationSpeed() * 10.f); if(status.fastSpin > 0) { nextRotation += abs((getSmootherStep(0, levelStatus.fastSpin, status.fastSpin) / 3.5f) * 17.f) * getSign(nextRotation); status.fastSpin -= mFT; } backgroundCamera.turn(nextRotation); }
void HexagonGame::incrementDifficulty() { playSound("level_up"); setSpeedMultiplier(getSpeedMultiplier() + levelData.getSpeedIncrement()); setRotationSpeed(getRotationSpeed() + levelData.getRotationSpeedIncrement()); setDelayMultiplier(getDelayMultiplier() + levelData.getDelayIncrement()); rotationDirection = !rotationDirection; fastSpin = levelData.getFastSpin(); if(randomSideChangesEnabled) timeline.add(new Do([&] { randomSideChange(); })); }
inline void HexagonGame::updateRotation(float mFrameTime) { auto nextRotation = getRotationSpeed() * 10 * mFrameTime; if(rotationDirection) nextRotation *= -1; if(fastSpin > 0) { nextRotation += (getSmootherStep(0, 85, fastSpin) / 3.5f) * getSign(nextRotation) * mFrameTime * 17.0f; fastSpin -= mFrameTime; } gameSprite.rotate(nextRotation); }
void HexagonGame::newGame(const string& mId, bool mFirstPlay, float mDifficultyMult) { firstPlay = mFirstPlay; setLevelData(getLevelData(mId), mFirstPlay); difficultyMult = mDifficultyMult; // Audio cleanup stopAllSounds(); playSound("go.ogg"); stopLevelMusic(); playLevelMusic(); // Events cleanup clearMessage(); for(auto eventPtr : eventPtrs) delete eventPtr; eventPtrs.clear(); while(!eventPtrQueue.empty()) { delete eventPtrQueue.front(); eventPtrQueue.pop(); } eventPtrQueue = queue<EventData*>{}; // Game status cleanup status = HexagonGameStatus{}; restartId = mId; restartFirstTime = false; setSides(levelData.getSides()); // Manager cleanup manager.clear(); factory.createPlayer(); // Timeline cleanup timeline.clear(); timeline.reset(); messageTimeline.clear(); messageTimeline.reset(); effectTimelineManager.clear(); // FPSWatcher reset fpsWatcher.reset(); if(getOfficial()) fpsWatcher.enable(); // LUA context cleanup if(!mFirstPlay) runLuaFunction<void>("onUnload"); lua = Lua::LuaContext{}; initLua(); runLuaFile(levelData.getValueString("lua_file")); runLuaFunction<void>("onLoad"); // Random rotation direction if(getRnd(0, 100) > 50) setRotationSpeed(getRotationSpeed() * -1); // Reset zoom overlayCamera.setView({{getWidth() / 2.f, getHeight() / 2.f}, sf::Vector2f(getWidth(), getHeight())}); backgroundCamera.setView({{0, 0}, {getWidth() * getZoomFactor(), getHeight() * getZoomFactor()}}); backgroundCamera.setRotation(0); // 3D Cameras cleanup depthCameras.clear(); unsigned int depth{styleData.get3DDepth()}; if(depth > get3DMaxDepth()) depth = get3DMaxDepth(); for(unsigned int i{0}; i < depth; ++i) depthCameras.push_back({window, {}}); }