void Platform::Move(sf::Time &deltaTime) { //find the correct bools if(m_left > m_posMaxFinal) m_isMovingLeft = true; else { m_isMovingLeft = false; m_posMaxFinal = m_posMaxTwo; } if((m_right - m_size.x) < m_posMaxFinal) m_isMovingRight = true; else { m_isMovingRight = false; m_posMaxFinal = m_posMaxOne; } //turn bools into floats if(m_isMovingLeft) m_movement.x -= m_movSpeedAddition * deltaTime.asMilliseconds(); if(m_isMovingRight) m_movement.x += m_movSpeedAddition * deltaTime.asMilliseconds(); //don't go over max if(m_movement.x >= m_movSpeedMax) m_movement.x = m_movSpeedMax; if(m_movement.x <= -m_movSpeedMax) m_movement.x = -m_movSpeedMax; m_rect.move(m_movement); m_sprite.move(m_movement); }
void Pad::update(sf::Time delta) { pad.move(movement.x * delta.asMilliseconds(), movement.y * delta.asMilliseconds()); float x = pad.getPosition().x; float y = pad.getPosition().y; if(x < boundOrigin.x) { pad.setPosition(boundOrigin.x,y); } if(x + size.x > boundOrigin.x + boundArea.x) { pad.setPosition(boundOrigin.x + boundArea.x - size.x,y); } if(y < boundOrigin.y) { pad.setPosition(x,boundOrigin.y); } if(y + size.y > boundOrigin.y + boundArea.y) { pad.setPosition(x,boundOrigin.y + boundArea.y - size.y); } }
void Engine::update(sf::Time dt) { m_entMgr->update(dt.asMicroseconds()); if(Stats::get()->getLives() < 0) m_exit = true; m_dbg->update(dt.asMilliseconds(), m_entMgr->getPlayer()->getPos()); }
void Map::update(const sf::Time& elapsed_time, uint score) { // How many pixels of moving float move = elapsed_time.asMilliseconds() * _speed; // Move backgrounds for(sf::Sprite& background : _backgrounds) { background.move(-move, 0); if(background.getPosition().x < -_width ) background.move(_width * 2, 0); } // Move clouds for( sf::Sprite& cloud : _clouds ) { cloud.move(-move, 0); if(cloud.getPosition().x < -cloud.getGlobalBounds().width) positionCloud(cloud, _width); } // Move bird if( score > _bird_score_limit ) { _bird.move(-move * _bird_speed_modificator, 0); // Bird goes out of screen, randomly re-place it const static float bird_screen_limit = - _bird.getGlobalBounds().width; if( _bird.getPosition().x < bird_screen_limit ) placeBird(); } std::cout << _bird.getPosition().x << std::endl; // Take care of trees (move and generate) updateTrees(move, score); }
void Player::Animate(sf::Time &deltaTime) { if(m_isMovingRight || m_isMovingLeft) { frameCounter += frameSpeed * deltaTime.asMilliseconds() * 0.001; if(frameCounter >= switchFrame) { frameCounter = 0; source.x++; if(source.x * 32 >= 32*3) source.x = 0; } } if(m_isMovingRight) source.y = 2; //source corresponds with .png else if(m_isMovingLeft) source.y = 1; else if(m_onGround) { source.y = 0; source.x = 1; } else if(!m_onGround) { //source.y = 3; Take out the looking back while falling: Quality of life change for CHRIS ZITNIK - WHAT A GUY source.y = 0; source.x = 1; } m_sprite.setTextureRect(sf::IntRect(source.x * 32, source.y * 32, 32, 32)); //make sure that texture is 32!! }
/// Update the current game state void Application::update() { const sf::Time elapsedTime = clock_.restart(); if(currentState_) currentState_->update(elapsedTime.asMilliseconds()); uiCtx_->Update(); }
virtual void draw(sf::Time deltaTime) { float tedeuszWajhePrzeusz=200; if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)) vel.x-=50; if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)) vel.x+=50; if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)) vel.y-=50; if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) vel.y+=50; float l = std::min(500.0f, Utils::vecLength(vel)); Utils::normalize(vel); vel*=l; aspPlayer.move(vel.x*deltaTime.asSeconds(), vel.y*deltaTime.asSeconds()); aspPlayer.update(l*deltaTime.asMilliseconds()/100.0f); vel*=0.9f; if (vel.x<0 && aspPlayer.getAnim()!=&aLeft) aspPlayer.setAnimation(&aLeft); if (vel.x>0 && aspPlayer.getAnim()!=&aRight) aspPlayer.setAnimation(&aRight); for(int i = 0; i < vecLvlData.size(); i++){ if(Collision::PixelPerfectTest(vecLvlData[i].sprite, aspPlayer)){ sceneManager->setActiveScene(vecLvlData[i].nginName); } } window->clear(); backgroundSprite.setScale( window->getSize().x / backgroundSprite.getLocalBounds().width, window->getSize().y / backgroundSprite.getLocalBounds().height); window->draw(backgroundSprite); window->draw(logoSprite); for(int i = 0; i < vecLvlData.size(); i++){ window->draw(vecLvlData[i].sprite); sf::Text description = sf::Text(vecLvlData[i].name, Common::Font::Comic_Sans); description.setScale(0.7, 0.7); description.setPosition(vecLvlData[i].sprite.getGlobalBounds().left + vecLvlData[i].sprite.getGlobalBounds().width/2.0 - description.getGlobalBounds().width/2.0, vecLvlData[i].sprite.getGlobalBounds().top+vecLvlData[i].sprite.getGlobalBounds().height); if(!sceneManager->scenes[vecLvlData[i].nginName]->isLocked()){ description.setColor(sf::Color(0.0, 255.0, 0.0, 255.0)); } else{ description.setColor(sf::Color(52.0, 25.0, 255.0, 255.0)); } window->draw(description); if (Utils::isMouseOnSprite(vecLvlData[i].sprite, window) && sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { sceneManager->setActiveScene(vecLvlData[i].nginName); } } window->draw(aspPlayer); }
void NSFSoundStream::onSeek(sf::Time timeOffset) { sf::Lock lock(mutex); if(!activeSamplers.empty()) { auto & sampler = activeSamplers.front(); auto & emu = sampler.first; handleError(emu->seek(static_cast<long>(timeOffset.asMilliseconds()))); } }
void Player::updateSpeed(const sf::Time& elapsed_time) { // Update speed if( isMoving() ) { if(isMaxSpeedReached()) return; // Speed gain depending on elapsed time float speed_gain = elapsed_time.asMilliseconds() * _acceleration; // Moving to left means minus speed if( _moving_to_direction == Direction::Left ) speed_gain = -speed_gain; // Update speed _horizontal_speed += speed_gain; // Respect max speed if( std::abs(_horizontal_speed) > _max_speed ) _horizontal_speed = ( _moving_to_direction == Direction::Left ) ? -_max_speed : _max_speed; } // Not moving, but remaining inertia else if( _horizontal_speed != 0.f ) { // Speed loss depending on elapsed time float speed_loss = elapsed_time.asMilliseconds() * _deceleration; if( _horizontal_speed > 0.f ) { _horizontal_speed -= speed_loss; if(_horizontal_speed < 0.f) _horizontal_speed = 0.f; } else if( _horizontal_speed < 0.f ) { _horizontal_speed += speed_loss; if(_horizontal_speed > 0.f) _horizontal_speed = 0.f; } } }
template <typename Game> void update(const sf::Time & elapsedTime, Game *) { timer += elapsedTime.asMilliseconds(); if (timer > 50) { timer -= 50; frameIndex += 1; if (frameIndex == 4) { frameIndex = 3; killFlag = true; } } }
//Timer to keep track of the critter's status void Critter::tick(sf::Time pausedTime) { //The time when the game is not paused. pausedTime is used to keep track of the time when the game is paused. long elapsedTime = critterClock.getElapsedTime().asMilliseconds() - pausedTime.asMilliseconds(); //Determining the critter's status if (elapsedTime >= statusTime) { critterStatus = CritterStatus::NORMAL; } else if (critterStatus != CritterStatus::NORMAL && elapsedTime % 500 == 0) { //Critter is burned setHP(HP - 5); } }
void Enemy::updateColor(const sf::Time & elapsedTime) { if (colored) { colorTimer += elapsedTime.asMilliseconds(); if (colorTimer > 20.f) { colorTimer -= 20.f; colorAmount -= 0.1f; } } if (colorAmount <= 0.f) { colored = false; } }
void Dasher::Blur::update(const sf::Time & elapsedTime) { timer += elapsedTime.asMilliseconds(); if (timer > 18) { timer = 0; sf::Color c = spr.getColor(); if (c.a > 30) { c.a -= 30; spr.setColor(c); } else { killflag = true; } } }
// NDK/JNI sub example - call Java code from native code int vibrate(sf::Time duration) { // First we'll need the native activity handle ANativeActivity *activity = sf::getNativeActivity(); // Retrieve the JVM and JNI environment JavaVM* vm = activity->vm; JNIEnv* env = activity->env; // First, attach this thread to the main thread JavaVMAttachArgs attachargs; attachargs.version = JNI_VERSION_1_6; attachargs.name = "NativeThread"; attachargs.group = NULL; jint res = vm->AttachCurrentThread(&env, &attachargs); if (res == JNI_ERR) return EXIT_FAILURE; // Retrieve class information jclass natact = env->FindClass("android/app/NativeActivity"); jclass context = env->FindClass("android/content/Context"); // Get the value of a constant jfieldID fid = env->GetStaticFieldID(context, "VIBRATOR_SERVICE", "Ljava/lang/String;"); jobject svcstr = env->GetStaticObjectField(context, fid); // Get the method 'getSystemService' and call it jmethodID getss = env->GetMethodID(natact, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;"); jobject vib_obj = env->CallObjectMethod(activity->clazz, getss, svcstr); // Get the object's class and retrieve the member name jclass vib_cls = env->GetObjectClass(vib_obj); jmethodID vibrate = env->GetMethodID(vib_cls, "vibrate", "(J)V"); // Determine the timeframe jlong length = duration.asMilliseconds(); // Bzzz! env->CallVoidMethod(vib_obj, vibrate, length); // Free references env->DeleteLocalRef(vib_obj); env->DeleteLocalRef(vib_cls); env->DeleteLocalRef(svcstr); env->DeleteLocalRef(context); env->DeleteLocalRef(natact); // Detach thread again vm->DetachCurrentThread(); }
void GraphicsSystem::update( Engine& engine, World& world, SaveManager& saveManager, const sf::Time& frameTime ) { r_renderWindow->setActive( true ); engine.renderWindow.setTitle( m_configValues.window_name + " " + to_string( frameTime.asMilliseconds() ) + " | EntityCount: " + to_string( world.getEntityCount() ) ); drawFunction(); return; }
void DrawableEffect::update(const sf::Time& elapsed_time) { sf::Int32 elapsed_ms; if(!_infinite) { elapsed_ms = ((elapsed_time > _duration) ? _duration : elapsed_time).asMilliseconds(); _duration -= elapsed_time; } else elapsed_ms = elapsed_time.asMilliseconds(); applyUpdate(elapsed_ms); }
void Update(sf::Time& deltaTime) { mTimeSinceLast = deltaTime.asMilliseconds() - mTimeSinceLast; sf::IntRect screen(0, 0, 1280, 720); if (!screen.contains((int)this->GetPosition().x, (int)this->GetPosition().y)) SetAlive(false); if (mHasFired) { if (mElapsed > mAimpointUpdateDelayMs) { mCurrentAimpoint = mFinalAimpoint; mElapsed = 0; mAimpointUpdated = true; UpdateAngle(); } else { mElapsed += mTimeSinceLast; } if ((GetRotation() > mDesiredAngle + 1) || (GetRotation() < mDesiredAngle - 1)) { if (mGuidanceOn) { if (mDesiredAngle > GetRotation()) SetRotation(GetRotation() + 0.25f); else SetRotation(GetRotation() - 0.25f); } } else { if (mAimpointUpdated) mGuidanceOn = false; } float velx = (float)(cos(Math::ToRadians(GetRotation() - 90.0f)) * mSpeed); float vely = (float)(sin(Math::ToRadians(GetRotation() - 90.0f)) * mSpeed); SetVelocity(sf::Vector2f(velx, vely)); } Sprite::Update(deltaTime); }
sf::IntRect EasyAnimationHandler::getTextureRect( const std::string& state, const sf::Time& internalTime ) const { auto& stateref = m_states.at( state ); int frame; sf::Int32 timeAsMilliseconds; if( std::get<2>( stateref ) ) { auto stateDuration = getStateDuration( state ).asMilliseconds(); timeAsMilliseconds = r_syncedTime->asMilliseconds() % stateDuration; } else { timeAsMilliseconds = internalTime.asMilliseconds(); } frame = (timeAsMilliseconds - (timeAsMilliseconds%durationPerFrame)) / durationPerFrame; return sf::IntRect( frame*texrect_x, get<0>( stateref )*texrect_y, texrect_x, texrect_y ); }
void Movie_audio::setPlayingOffset(sf::Time time) { sf::SoundStream::stop(); // TODO: does not work yet // TODO: apply float -> Uin32 change AVRational tb = m_parent.getAVFormatContext()->streams[m_streamID]->time_base; float ftb = (float)tb.num / tb.den; int64_t avTime = time.asMilliseconds() * ftb; int res = av_seek_frame(m_parent.getAVFormatContext(), m_streamID, avTime, AVSEEK_FLAG_BACKWARD); if (res < 0) std::cerr << "Movie_audio::SetPlayingOffset() - av_seek_frame() failed" << std::endl; else { while (m_packetList.size()) { popFrame(); } sf::SoundStream::play(); } }
void Map::update(const sf::Time& elapsed_time) { _player.update(elapsed_time); // Update player position if( _player.hasSpeed() ) { // Calculate destination float x_move = _player.getHorizontalSpeed() * elapsed_time.asMilliseconds(); float x_destination = _player.getPosition().x + x_move; float y_destination = _player.getPosition().y; // Check movement doesn't reach limits if( x_destination < _map_left_limit ) { x_destination = _map_left_limit; _player.resetMovement(); // player's reach limit, reset movement inertia } else if( x_destination + _player.getWidth() > _map_right_limit ) { x_destination = _map_right_limit - _player.getWidth(); _player.resetMovement(); // player's reach limit, reset movement inertia } // Update player and view positions _player.setPosition( {x_destination, y_destination} ); _view.setCenter( _player.getCenter() ); // Check view's limits not reached const sf::Vector2f& view_center = _view.getCenter(); if( view_center.x < _view_left_limit ) _view.setCenter( _view_left_limit, view_center.y ); else if( view_center.x > _view_right_limit ) _view.setCenter( _view_right_limit, view_center.y ); } keyboardActions(); }
void Player::Move(sf::Time &deltaTime, Tilemap &t) { //moving right and slowing down if(m_isMovingRight == true) m_movement.x += m_movSpeedConst * deltaTime.asMilliseconds(); else if(m_isMovingRight == false && m_movement.x > 0) { m_movement.x -= m_movSpeedConst * 1.5 * deltaTime.asMilliseconds(); if(m_movement.x < 0) m_movement.x = 0; } //moving left and slowing down if(m_isMovingLeft == true) m_movement.x -= m_movSpeedConst * deltaTime.asMilliseconds(); else if(m_isMovingLeft == false && m_movement.x < 0) { m_movement.x += m_movSpeedConst* 1.5 * deltaTime.asMilliseconds(); if(m_movement.x > 0) m_movement.x = 0; } //not over max speed if(m_movement.x >= m_movSpeedMax) m_movement.x = m_movSpeedMax; else if(m_movement.x <= -m_movSpeedMax) m_movement.x = -m_movSpeedMax; //don't move left right if colliding with wall if(int(m_bottom) % 64 == 0 && (t.getLevelMap((m_bottom + 2)/64, m_left/64) == 192 || t.getLevelMap((m_bottom + 2)/64, m_left/64) == 191 || t.getLevelMap((m_bottom + 2)/64, m_right/64) == 191 || t.getLevelMap((m_bottom + 2)/64, m_right/64) == 190 || t.getLevelMap((m_bottom + 2)/64, m_left/64) == 192 || t.getLevelMap((m_bottom + 2)/64, m_left/64) == 592 || t.getLevelMap((m_bottom + 2)/64, m_left/64) == 591 || t.getLevelMap((m_bottom + 2)/64, m_right/64) == 591 || t.getLevelMap((m_bottom + 2)/64, m_right/64) == 590)) {} else if((t.getLevelMap(m_bottom/64, m_left/64) == 192 || t.getLevelMap(m_bottom/64, m_left/64) == 292 || t.getLevelMap(m_bottom/64, m_left/64) == 392 || t.getLevelMap(m_bottom/64, m_left/64) == 490 || t.getLevelMap(m_bottom/64, m_left/64) == 592 || t.getLevelMap(m_bottom/64, m_left/64) == 191 || t.getLevelMap(m_bottom/64, m_left/64) == 291 || t.getLevelMap(m_bottom/64, m_left/64) == 391 || t.getLevelMap(m_bottom/64, m_left/64) == 491 || t.getLevelMap(m_bottom/64, m_left/64) == 591) && m_movement.x < 0) m_movement.x = 0; else if((t.getLevelMap(m_bottom/64, m_right/64) == 190 || t.getLevelMap(m_bottom/64, m_right/64) == 290 || t.getLevelMap(m_bottom/64, m_right/64) == 390 || t.getLevelMap(m_bottom/64, m_right/64) == 492 || t.getLevelMap(m_bottom/64, m_right/64) == 590 || t.getLevelMap(m_bottom/64, m_right/64) == 191 || t.getLevelMap(m_bottom/64, m_right/64) == 291 || t.getLevelMap(m_bottom/64, m_right/64) == 391 || t.getLevelMap(m_bottom/64, m_right/64) == 491 || t.getLevelMap(m_bottom/64, m_right/64) == 591) && m_movement.x > 0) m_movement.x = 0; else if((t.getLevelMap((m_top + 2)/64, m_left/64) == 192 || t.getLevelMap((m_top + 2)/64, m_left/64) == 292 || t.getLevelMap((m_top + 2)/64, m_left/64) == 392 || t.getLevelMap((m_top + 2)/64, m_left/64) == 490 || t.getLevelMap((m_top + 2)/64, m_left/64) == 592 || t.getLevelMap((m_top + 2)/64, m_left/64) == 191 || t.getLevelMap((m_top + 2)/64, m_left/64) == 291 || t.getLevelMap((m_top + 2)/64, m_left/64) == 391 || t.getLevelMap((m_top + 2)/64, m_left/64) == 491 || t.getLevelMap((m_top + 2)/64, m_left/64) == 591) && m_movement.x < 0) m_movement.x = 0; else if((t.getLevelMap((m_top + 2)/64, m_right/64) == 190 || t.getLevelMap((m_top + 2)/64, m_right/64) == 290 || t.getLevelMap((m_top + 2)/64, m_right/64) == 390 || t.getLevelMap((m_top + 2)/64, m_right/64) == 492 || t.getLevelMap((m_top + 2)/64, m_right/64) == 590 || t.getLevelMap((m_top + 2)/64, m_right/64) == 191 || t.getLevelMap((m_top + 2)/64, m_right/64) == 291 || t.getLevelMap((m_top + 2)/64, m_right/64) == 391 || t.getLevelMap((m_top + 2)/64, m_right/64) == 491 || t.getLevelMap((m_top + 2)/64, m_right/64) == 591) && m_movement.x > 0) m_movement.x = 0; //don't move if colliding with a colliding crate! for(int i = 0; i < t.getCrateSize(); i++) { if(t.getCrateOnLeft(i) == true || t.getCrateOnRight(i) == true) { if(m_right < t.getCrateLeft(i) || m_left > t.getCrateRight(i) || m_top > t.getCrateBottom(i) || m_bottom < t.getCrateTop(i)) {} else if(m_right >= t.getCrateLeft(i) && (m_right + m_left)/2 <= t.getCrateLeft(i) && m_movement.x > 0 &&(m_bottom - 2) >= t.getCrateTop(i)) m_movement.x = 0; else if(m_left <= t.getCrateRight(i) && (m_right + m_left)/2 >= t.getCrateLeft(i) && m_movement.x < 0 && (m_bottom - 2) >= t.getCrateTop(i)) m_movement.x = 0; } } //jumping if(sf::Keyboard::isKeyPressed(sf::Keyboard::W) || sf::Keyboard::isKeyPressed(sf::Keyboard::Space) || sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) m_jumped = true; //if hit top of block, fall if((t.getLevelMap(m_top/64, (m_left + 2)/64) == 190 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 190 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 191 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 191 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 192 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 192 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 290 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 290 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 291 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 291 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 292 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 292 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 390 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 390 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 391 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 391 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 392 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 392 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 490 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 490 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 491 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 491 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 492 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 492 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 590 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 590 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 591 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 591 || t.getLevelMap(m_top/64, (m_left + 2)/64) == 592 || t.getLevelMap(m_top/64, (m_right - 2)/64) == 592) && m_movement.y < 0) m_movement.y = 0; //setting jump stuff if(m_jumped == true && m_onGround == true) { m_movement.y = -m_gravity; m_jumped = false; } else { m_jumped = false; if(!m_onGround) m_movement.y += m_gravity * 0.003 * deltaTime.asMilliseconds(); else m_movement.y = 0; if(m_movement.y > 0.5) m_movement.y = 0.5; } //move if on a platform for(int i = 0; i < t.getPlatformSize(); i++) { //not touching if(m_right < t.getPlatformLeft(i) || m_left > t.getPlatformRight(i) || m_top > t.getPlatformBottom(i) || m_bottom < t.getPlatformTop(i)) {} else if(m_bottom - 2 > t.getPlatformTop(i)) {} else if(m_left > t.getPlatformLeft(i) && m_right < t.getPlatformRight(i)) m_movement.x += t.getPlatformMovement(i).x; else if( m_left < t.getPlatformLeft(i) && (m_left + m_right)/2 > t.getPlatformLeft(i) && int(m_movement.x) == 0) m_movement.x += t.getPlatformMovement(i).x; else if( m_right > t.getPlatformRight(i) && (m_left + m_right)/2 < t.getPlatformRight(i) && int(m_movement.x) == 0) m_movement.x += t.getPlatformMovement(i).x; } //move if on a crate (movement will be non-zero if crate is on a platform so...) /*for(int i = 0; i < t.getCrateSize(); i++) { if(m_right < t.getCrateLeft(i) || m_left > t.getCrateRight(i) || m_top > t.getCrateBottom(i) || m_bottom < t.getCrateTop(i)) {} else if(int(m_bottom) <= t.getCrateTop(i)) m_movement.x += t.getCrateMovement(i).x; }*/ //the actual move part m_rect.move(m_movement.x, m_movement.y); m_sprite.move(m_movement.x, m_movement.y); //change the movement after actually moving so it doesn't mess up earlier processes for(int i = 0; i < t.getPlatformSize(); i++) { //not touching if(m_right < t.getPlatformLeft(i) || m_left > t.getPlatformRight(i) || m_top > t.getPlatformBottom(i) || m_bottom < t.getPlatformTop(i)) {} else if(m_bottom - 2 > t.getPlatformTop(i)) {} else if(m_left > t.getPlatformLeft(i) && m_right < t.getPlatformRight(i)) m_movement.x -= t.getPlatformMovement(i).x; else if( m_left < t.getPlatformLeft(i) && (m_left + m_right)/2 > t.getPlatformLeft(i) && int(m_movement.x) == 0) m_movement.x -= t.getPlatformMovement(i).x; else if( m_right > t.getPlatformRight(i) && (m_left + m_right)/2 < t.getPlatformRight(i) && int(m_movement.x) == 0) m_movement.x -= t.getPlatformMovement(i).x; } //change the movement after actually moving the crate so it doesn't mess up earlier processes /*for(int i = 0; i < t.getCrateSize(); i++) { if(m_right < t.getCrateLeft(i) || m_left > t.getCrateRight(i) || m_top > t.getCrateBottom(i) || m_bottom < t.getCrateTop(i)) {} else if(int(m_bottom) <= t.getCrateTop(i)) m_movement.x -= t.getCrateMovement(i).x; }*/ /*if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W)) //FOR GOD MODE!! m_movement.y = -0.25; else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S)) m_movement.y = 0.25; else m_movement.y = 0; if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)) m_movement.x = -0.25; if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D)) m_movement.x = 0.25; */ }
virtual void draw(sf::Time deltaTime){ double dT = deltaTime.asMilliseconds(); tmpTime += dT; for(KeyText& kt: vecKeyTexts){ kt.update(dT); } actSprite.update(dT); spriteDaft1.update(dT); spriteDaft2.update(dT); if(actSprite.getReplays() != 0){ setDanceStep(&vecSteps[rand()%vecSteps.size()]); } if(spriteDaft1.getReplays() != 0){ setDanceStepDP(1); } if(spriteDaft2.getReplays() != 0){ setDanceStepDP(2); } for(StepPose& sp: actStep->vecPoses){ if(actSprite.getFrame() == sp.tempoPosition && !sp.used){ addKey(sp.limb); sp.used=true; } } for(int i = vecText.size()-1; i>=0; i--){ vecText[i].time -= dT; if(vecText[i].time < 0.0){ vecText.erase(vecText.begin()+i); } } for(int i = vecKeyTexts.size()-1; i >= 0; i--){ if(vecKeyTexts[i].timeCtr > vecKeyTexts[i].duration){ vecKeyTexts.erase(vecKeyTexts.begin()+i); displayText(vecDiscoReactionsBad[rand()%vecDiscoReactionsBad.size()], 0); score--; } } if(actMusic.getStatus() == sf::SoundSource::Status::Stopped){ loadNewTrack(); } window->clear(sf::Color::Black); window->draw(background); window->draw(spriteDaft1.sprite); window->draw(spriteDaft2.sprite); for(auto txt: vecText){ window->draw(txt.text); } window->draw(actSprite.sprite); sf::RectangleShape rectangle(sf::Vector2f(2*actSprite.sprite.getGlobalBounds().width, 20.0f)); rectangle.setPosition(actSprite.sprite.getPosition()); rectangle.move(-actSprite.sprite.getGlobalBounds().width/2, -radius-20); rectangle.setFillColor(sf::Color(40.0, 150.0, 40.0)); window->draw(rectangle); rectangle.setFillColor(sf::Color::Green); rectangle.setSize(sf::Vector2f((score/100.0)*(2*actSprite.sprite.getGlobalBounds().width), 20.0f)); window->draw(rectangle); for(KeyText ks: vecKeyTexts) window->draw(ks); dbgText.setString(Utils::stringify(actSprite.getFrame())+"/"+Utils::stringify(actSprite.framesSize())); window->draw(dbgText); if(score >= 100){ sceneManager->callMeBaby(); actMusic.stop(); } }
void Dasher::update(Game * pGame, const std::vector<wall> & walls, const sf::Time & elapsedTime) { auto & effects = pGame->getEffects(); auto & details = pGame->getDetails(); auto & player = pGame->getPlayer(); if (health > 0) { for (auto & element : effects.get<EffectRef::PlayerShot>()) { if (hitBox.overlapping(element->getHitBox()) && element->checkCanPoof()) { if (health == 1) { element->disablePuff(); element->setKillFlag(); } element->poof(); health -= 1; colored = true; colorAmount = 1.f; } } for (auto & helper : pGame->getHelperGroup().get<HelperRef::Laika>()) { if (hitBox.overlapping(helper->getHitBox())) { health = 0; } } if (health == 0) { hSpeed = 0; vSpeed = 0; frameIndex = 0; killFlag = true; details.add<DetailRef::DasherCorpse>( this->getPosition(), getgResHandlerPtr()->getTexture( ResHandler::Texture::gameObjects), dasherSheet.getScale().x); unsigned long int temp = rng::random<4>(); if (temp < 1) { effects.add<EffectRef::Heart>( getgResHandlerPtr()->getTexture( ResHandler::Texture::gameObjects), getgResHandlerPtr()->getTexture( ResHandler::Texture::redglow), position.x, position.y + 4, Item::Type::Heart); } else if (temp < 3) { effects.add<EffectRef::GoldHeart>( getgResHandlerPtr()->getTexture( ResHandler::Texture::gameObjects), getgResHandlerPtr()->getTexture( ResHandler::Texture::yellowGlow), position.x, position.y + 4, Item::Type::GoldHeart); } else { effects.add<EffectRef::Coin>( getgResHandlerPtr()->getTexture( ResHandler::Texture::gameObjects), getgResHandlerPtr()->getTexture( ResHandler::Texture::blueglow), position.x, position.y + 4, Item::Type::Coin); } effects.add<EffectRef::SmallExplosion>( getgResHandlerPtr()->getTexture( ResHandler::Texture::gameObjects), getgResHandlerPtr()->getTexture( ResHandler::Texture::fireExplosionGlow), position.x, position.y - 2); blurEffects.clear(); } } SoundController & sounds = pGame->getSounds(); Enemy::updateColor(elapsedTime); dasherSheet.setPosition(position.x + 4, position.y); shadow.setPosition(position.x - 4, position.y + 22); hitBox.setPosition(position.x, position.y); timer += elapsedTime.asMilliseconds(); auto facePlayer = [this, player]() { if (this->position.x > player.getXpos()) { this->dasherSheet.setScale(1, 1); } else { this->dasherSheet.setScale(-1, 1); } }; switch (state) { case State::idle: if (timer >= 200) { timer -= 200; const int select = rng::random<2>(); if (select) { state = State::dashBegin; frameIndex = 1; } else { state = State::shootBegin; frameIndex = 3; } } break; case State::pause: if (timer >= 200) { timer -= 200; state = State::dashBegin; frameIndex = 1; } break; case State::shooting: facePlayer(); frameTimer += elapsedTime.asMilliseconds(); if (frameTimer > 80 && shotCount < 3) { frameTimer -= 80; shotCount++; if (position.x > player.getXpos()) { effects.add<EffectRef::TurretFlashEffect>( getgResHandlerPtr()->getTexture( ResHandler::Texture::gameObjects), position.x - 14, position.y + 2); effects.add<EffectRef::DasherShot>( position.x - 12, position.y, angleFunction(target.x + 8, target.y + 8, position.x, position.y)); pGame->getSounds().play(ResHandler::Sound::silenced, this->shared_from_this(), 220.f, 5.f); } else { effects.add<EffectRef::TurretFlashEffect>( getgResHandlerPtr()->getTexture( ResHandler::Texture::gameObjects), position.x + 6, position.y + 2); effects.add<EffectRef::DasherShot>( position.x + 4, position.y, angleFunction(target.x, target.y + 8, position.x, position.y)); pGame->getSounds().play(ResHandler::Sound::silenced, this->shared_from_this(), 220.f, 5.f); } } if (timer > 300) { timer -= 300; shotCount = 0; state = State::pause; } break; case State::shootBegin: facePlayer(); if (timer > 80) { timer -= 80; frameTimer = 0; target = player.getPosition(); state = State::shooting; frameIndex = 4; } break; case State::dashBegin: begin: facePlayer(); if (timer > 352) { timer -= 352; state = State::dashing; sounds.play(ResHandler::Sound::wooshMono, this->shared_from_this(), 220.f, 5.f); frameIndex = 2; uint8_t tries{0}; float dir{static_cast<float>(rng::random<359>())}; do { tries++; if (tries > 254) { state = State::shootBegin; frameIndex = 3; goto begin; } dir += 12; } while (wallInPath(walls, dir, position.x, position.y)); hSpeed = 5 * cos(dir); vSpeed = 5 * sin(dir); if (hSpeed > 0) { dasherSheet.setScale(-1, 1); } else { dasherSheet.setScale(1, 1); dasherSheet.setScale(1, 1); } } break; case State::dashing: frameTimer += elapsedTime.asMilliseconds(); if (frameTimer > 40) { frameTimer = 0; blurEffects.emplace_back(dasherSheet.getSpritePtr(), position.x, position.y); } if (timer > 250) { timer -= 250; state = State::dashEnd; frameIndex = 1; hSpeed = 0.f; vSpeed = 0.f; } if (Enemy::checkWallCollision(walls, position.x, position.y)) { hSpeed *= -1.f; vSpeed *= -1.f; } break; case State::dashEnd: if (timer > 150) { blurEffects.clear(); timer -= 150; state = State::idle; frameIndex = 0; } break; } if (!blurEffects.empty()) { for (auto it = blurEffects.begin(); it != blurEffects.end();) { if (it->getKillFlag()) it = blurEffects.erase(it); else { it->update(elapsedTime); ++it; } } } position.x += hSpeed * (elapsedTime.asMicroseconds() * 0.00005f); position.y += vSpeed * (elapsedTime.asMicroseconds() * 0.00005f); }
void Player::Update(sf::Time DeltaTime) { if(slopeQue.size()>0 && checkSlope == true){ this->getSlope2(slopeQue); checkSlope = false; } if(alive == true){ if(health >= 3){ health = 3; healthGenerateValue = 0; } if(healthGenerateValue >= 10){ health +=1; healthGenerateValue = 0; } if(health <=0){ alive = false; } if(health >= 3){ m_Sprite.setTexture(*ImageManager::RequestTexture("Assets/Img/AvatarSprite.png", true, false, true)); }else if(health>=2){ m_Sprite.setTexture(*ImageManager::RequestTexture("Assets/Img/AvatarSprite_Hurt.png", true, false, true)); }else if(health>=1){ m_Sprite.setTexture(*ImageManager::RequestTexture("Assets/Img/AvatarSprite_Badly_Hurt.png", true, false, true)); } m_friction = m_glideFric; GUI::SetHearts(health); if(Input_disable==false){ if(Input.keyIdPressed(PhoenixEngine::GlobalConfig->GetInt("Controls", "Control_Weapon1"))){ currentWeapon = 1; GUI::SwitchTo((Weapon)(currentWeapon-1)); } if(Input.keyIdPressed(PhoenixEngine::GlobalConfig->GetInt("Controls", "Control_Weapon2"))){ currentWeapon = 2; GUI::SwitchTo((Weapon)(currentWeapon-1)); } if(Input.keyIdPressed(PhoenixEngine::GlobalConfig->GetInt("Controls", "Control_Weapon3"))){ currentWeapon = 3; GUI::SwitchTo((Weapon)(currentWeapon-1)); } if(Input.keyIdDown(PhoenixEngine::GlobalConfig->GetInt("Controls", "Control_Special"))){ if(GUI::GetBellowAmount() == 100){ Bellow_Attack(); GUI::setBellowAmount(0); } } if(Input.keyIdDown(PhoenixEngine::GlobalConfig->GetInt("Controls", "Control_Left"))) { m_Velocity.x -= m_acell*DeltaTime.asSeconds(); m_friction = m_moveFric; } if(Input.keyIdDown(PhoenixEngine::GlobalConfig->GetInt("Controls", "Control_Right"))) { m_Velocity.x += m_acell*DeltaTime.asSeconds(); m_friction = m_moveFric; } if(Input.keyIdDown(PhoenixEngine::GlobalConfig->GetInt("Controls", "Control_Up"))) { m_Velocity.y -= m_acell*DeltaTime.asSeconds(); m_friction = m_moveFric; } if(Input.keyIdDown(PhoenixEngine::GlobalConfig->GetInt("Controls", "Control_Down"))) { m_Velocity.y += m_acell*DeltaTime.asSeconds(); m_friction = m_moveFric; } } m_Velocity.x *= powf(m_friction, DeltaTime.asSeconds() / (1.0f / 30.0f)); m_Velocity.y *= powf(m_friction, DeltaTime.asSeconds() / (1.0f / 30.0f)); sf::Vector2f moveAmount = sf::Vector2f(m_Velocity.x * DeltaTime.asSeconds(), m_Velocity.y * DeltaTime.asSeconds()); if(bellowing==false){ m_Sprite.move(moveAmount); } if(m_Sprite.getPosition().y < 50){ m_Sprite.move(0, -moveAmount.y); } sf::Vector2i mousePos = Input.mousePos();//(sf::Vector2f)sf::Mouse::getPosition(*PhoenixEngine::GetWindow()) + ( m_Camera->getCenter() - sf::Vector2f( m_Camera->getSize().x/2, m_Camera->getSize().y/2 ) ); sf::Vector2f PlayerPos = (m_Sprite.getPosition() - (m_Camera->getCenter()-m_Camera->getSize()/2.0f)); PlayerPos.x *= (PhoenixEngine::GetWindow()->getSize().x / m_Camera->getSize().x); PlayerPos.y *= (PhoenixEngine::GetWindow()->getSize().y / m_Camera->getSize().y); float dx = mousePos.x - PlayerPos.x; float dy = mousePos.y - PlayerPos.y; float rotation = (atan2(dy, dx) * 180 / 3.14f); m_Sprite.setRotation(rotation); if(rotation>-90 && rotation < 90) { m_Sprite.setScale(1.0f, 1.0f); }else { m_Sprite.setScale(1.0f, -1.0f); } if(Input.keyIdDown(PhoenixEngine::GlobalConfig->GetInt("Controls", "Control_Fire"))){ sf::Vector2f shot_dir = sf::Vector2f (dx, dy); shoot(shot_dir); } if(currentReload > 0){ currentReload -= DeltaTime.asSeconds(); if(currentReload <= 0){ //reload done sound AudioManager::playSound("Assets/Audio/Sfx/ReloadSound.wav", 0.8f, 1.2f); AnimH.gotoAndPlay("reloadAnim", 1); GUI::ReloadDone(); } } if(AnimH.getCurrentAnimation()=="reloadAnim"){ if(AnimH.getCurrentFrame() == 5){ AnimH.gotoAndPlay("flyAnim", 6); } } if(AnimH.getCurrentAnimation() == "flyAnim"){ blinkTime += DeltaTime.asMilliseconds(); if(blinkTime>1000) { AnimH.gotoAndPlay("blinkAnim", 1); blinkTime = 0; } }else if(AnimH.getCurrentAnimation() == "blinkAnim"){ if(AnimH.getCurrentFrame()==30) { AnimH.play("flyAnim"); blinkTime = 0; } }else if(AnimH.getCurrentAnimation() == "atackAnim"){ if(AnimH.getCurrentFrame()==15) { AnimH.play("flyAnim"); } } }else{ if(superDead == false){ m_Velocity.y +=2000*DeltaTime.asSeconds(); sf::Vector2f moveAmount = sf::Vector2f(m_Velocity.x * DeltaTime.asSeconds(), m_Velocity.y * DeltaTime.asSeconds()); m_Sprite.move(moveAmount); float rotation = (atan2(m_Velocity.y, m_Velocity.x) * 180 / 3.14f); float rot = (rotation- m_Sprite.getRotation()) /100; m_Sprite.setRotation(m_Sprite.getRotation() + rot); AnimH.gotoAndStop("deadAnim", 1); } } if(damageColdDown > 0){ damageColdDown -= DeltaTime.asMilliseconds(); int blinksak = damageColdDown%400; if(blinksak>100){ sf::Color col = m_Sprite.getColor(); col.a = 10; m_Sprite.setColor(col); }else{ sf::Color col = m_Sprite.getColor(); col.a = 255; m_Sprite.setColor(col); } } AnimH.update(); // std::cout << std::endl << std::endl; // std::cout << "healthGenerateValue: " << healthGenerateValue << std::endl; // std::cout << "Health: " << health << std::endl; reflectedVector.x = 0; reflectedVector.y = 0; BW_Attack.Update(DeltaTime); //ParticleManager::Spawn(new SparkleEffect, m_Sprite.getPosition()); if(Input_disable==false && PhoenixEngine::GlobalConfig->GetBool("Controls", "bEnableScrollWeapons")){ if(Input.mouseWheelDown()){ //std::cout << "before: " << currentWeapon << std::endl; currentWeapon = ((currentWeapon)%3) +1; GUI::SwitchTo((Weapon)(currentWeapon-1)); //std::cout << "after: " << currentWeapon << std::endl; } if(Input.mouseWheelUp()){ //std::cout << "before: " << currentWeapon << std::endl; currentWeapon = ((currentWeapon-2+3)%3) +1; GUI::SwitchTo((Weapon)(currentWeapon-1)); //std::cout << "after: " << currentWeapon << std::endl; } } }
Music::Music(irrklang::ISound* sound, sf::Time startOffset, sf::Time finishOffset) { sound_ = sound; startOffset_ = startOffset.asMilliseconds(); sound_->setPlayPosition(startOffset_); finishOffset_ = (finishOffset == sf::microseconds(0)) ? (sound_->getPlayLength()) : (finishOffset.asMilliseconds()); }
void Music::SetPlayPosition(sf::Time time) { sound_->setPlayPosition(time.asMilliseconds()); }
void Player::Update(sf::Time elapsed, MB::EventList* events) { MB::GameComponent::Update(elapsed, events); int dirX = 0; int dirY = 0; bool moved = false; sf::Vector2f origPos(this->playerSprite.getPosition()); float origRot = this->playerSprite.getRotation(); Game* g = (Game*)this->game; /*if(g->HasFocus()){*/ if ( (this->actions->Exists("Player Move Up") && this->actions->Get("Player Move Up")->IsActive() ) || ( this->actions->Exists("Player Move Up Alt") && this->actions->Get("Player Move Up Alt")->IsActive())) { dirY = -1; moved = true; } if ( (this->actions->Exists("Player Move Down") && this->actions->Get("Player Move Down")->IsActive() ) || ( this->actions->Exists("Player Move Down Alt") && this->actions->Get("Player Move Down Alt")->IsActive())) { dirY = 1; moved = true; } if ( (this->actions->Exists("Player Move Left") && this->actions->Get("Player Move Left")->IsActive() ) || ( this->actions->Exists("Player Move Left Alt") && this->actions->Get("Player Move Left Alt")->IsActive())) { dirX = -1; moved = true; } if ( (this->actions->Exists("Player Move Right") && this->actions->Get("Player Move Right")->IsActive() ) || ( this->actions->Exists("Player Move Right Alt") && this->actions->Get("Player Move Right Alt")->IsActive())) { dirX = 1; moved = true; } //} sf::Vector2f direction(dirX,dirY); // Change position (based on elapsed time) // Limit elapsed time first float limitedElapsed = (float)elapsed.asMilliseconds(); if(limitedElapsed > 31.0f) { limitedElapsed = 31.0f; } sf::Vector2f velocity(dirX * 1.f * limitedElapsed, dirY * 1.f * limitedElapsed); // Now check collision sf::IntRect origRect(this->playerSprite.getGlobalBounds()); origRect.top = origPos.y; origRect.left = origPos.x; origRect.width = origRect.height = 32; // Slight offset correction (from origin) origRect.top -= 16; origRect.left -= 16; sf::Vector2f correctedVector = gameMap->collisionDetect(origRect, velocity, direction ) ; correctedVector.x += origPos.x; correctedVector.y += origPos.y; this->playerSprite.setPosition(correctedVector); // Set sprite orientation based on dir float rotation = 0.0f; // Diagonals if(dirY == -1 && dirX == -1) { rotation = 315.0f; } else if(dirY == -1 && dirX == 1) { rotation = 45.0f; } else if(dirY == 1 && dirX == -1) { rotation = 225.0f; } else if(dirY == 1 && dirX == 1) { rotation = 135.0f; } if(rotation == 0.0f) { if(dirY == 1) { rotation = 180.0f; } else if(dirX == -1) { rotation = 270.0f; } else if(dirX == 1) { rotation = 90.0f; } } this->playerSprite.setRotation(rotation); if(moved) { // Update the local copy of weapon hitbox only if moved UpdateWeaponHitBox(); this->directionVector = sf::Vector2i(dirX,dirY); // Send Packet Packets packets; WorkQueues::packetsToSend().push(packets.CreateSendThisPlayerPos(playerSprite.getPosition(),playerSprite.getRotation())); } else { this->playerSprite.setRotation(origRot); } if ( (this->actions->Exists("UseItem") && this->actions->Get("UseItem")->IsActive()) || (this->actions->Exists("UseItem Alt") && this->actions->Get("UseItem Alt")->IsActive()) ) { this->UseItem(); } this->attacking = false; if (this->game->GetActions()->Exists("Attack") && this->game->GetActions()->Get("Attack")->IsActive()) { this->attacking = true; this->Attack(); } }
Blink::Blink(const std::shared_ptr<Drawable>& target, const sf::Time& duration, const sf::Time& blink_time) : DrawableEffect {target, duration} , _blink_time {blink_time.asMilliseconds()} {}
void animationUpdate(sf::Time elapsed, vectorObjects shapes) { shapes.sec->rotate(elapsed.asSeconds() * 6); shapes.min->rotate(elapsed.asMilliseconds() * 0.0001f); shapes.hour->rotate(elapsed.asMilliseconds() * 0.00001f / 6); }
void Bullet_bounce::Update(sf::Time DeltaTime) { if(damage == 2){ bColor.r = 243; bColor.g = 246; bColor.b = 10; m_Sprite.setColor(bColor); } if(damage == 4){ bColor.r = 246; bColor.g = 138; bColor.b = 10; m_Sprite.setColor(bColor); } if(damage == 8){ bColor.r = 246; bColor.g = 10; bColor.b = 10; m_Sprite.setColor(bColor); } if(slopeQue.size()>0 && checkSlope == true){ this->getSlope2(slopeQue); checkSlope = false; } tailTime += DeltaTime.asMilliseconds(); if(drawAmount<10){ drawAmount +=1; } sf::Vector2f moveSpeed; moveSpeed.x = m_Velocity.x * DeltaTime.asSeconds(); moveSpeed.y = m_Velocity.y * DeltaTime.asSeconds(); m_Sprite.move(moveSpeed); float myRadians = atan2(m_Velocity.y, m_Velocity.x); float myDegrees = (float)(myRadians*180/M_PI); m_Sprite.setRotation(myDegrees); tail[0]->setPosition( tail[0]->getPosition().x + directionVec[0].x * speed * DeltaTime.asSeconds(), tail[0]->getPosition().y + directionVec[0].y * speed * DeltaTime.asSeconds()); if(Util::getLenght(tail[0]->getPosition() - m_Sprite.getPosition()) >= 30){ directionVec[0] = Util::getNormalVector(m_Velocity); tail[0]->setPosition( m_Sprite.getPosition().x - directionVec[0].x * 20.0f, m_Sprite.getPosition().y - directionVec[0].y * 20.0f); float myRadians = atan2(directionVec[0].y, directionVec[0].x); float myDegrees = (float)(myRadians*180/M_PI); tail[0]->setRotation(myDegrees); tail[0]->setColor(m_Sprite.getColor()); } for(int i = 1; i < tail.size(); i++){ tail[i]->setPosition( tail[i]->getPosition().x + directionVec[i].x * speed * DeltaTime.asSeconds(), tail[i]->getPosition().y + directionVec[i].y * speed * DeltaTime.asSeconds()); if(Util::getLenght(tail[i]->getPosition() - tail[i-1]->getPosition()) >= 30){ directionVec[i] = directionVec[i-1]; tail[i]->setPosition( tail[i-1]->getPosition().x - directionVec[i].x * 20.0f, tail[i-1]->getPosition().y - directionVec[i].y * 20.0f); float myRadians = atan2(directionVec[i].y, directionVec[i].x); float myDegrees = (float)(myRadians*180/M_PI); tail[i]->setRotation(myDegrees); tail[i]->setColor(tail[i-1]->getColor()); } } time += DeltaTime.asMilliseconds(); if(time> 4000){ deleteMe = true; } }