void GLWidget::paintGL() { updateAnimation(); updateViewport(); drawCatmullRomSpline(); drawControlPoints(); drawSelectedPoint(); }
FadeAnimation::FadeAnimation(int updateFps) : m_updateFps(updateFps) , m_fadeValue(0.0) , m_fadeIn(false) { m_timer.setInterval(1000 / updateFps); connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateAnimation())); }
GraphicsObject::GraphicsObject(Perso *obj) : QObject(), _perso(obj) { // Get images depending on the name QStringList direction_list; direction_list << "haut" << "bas" << "gauche" << "droite"; for(int i = 0 ; i < direction_list.size() ; ++ i) { // For each direction, we create a list of images QSharedPointer<ImageAnimation> img(new ImageAnimation()); img.data()->_current_img = 0; int tile_id = 0; bool file_exists = true; // Load image for this direction while files exist for this direction while(file_exists) { // Check for next file const QString filename = Constants::IMAGES_PERSOS_PATH + QString::fromStdString(obj->get_name()) + "_" + direction_list.at(i) + QString("_%1.png").arg(tile_id); if(QFile::exists(filename)) { // File exists, we load the pixmap img.data()->_items.append(new QGraphicsPixmapItem(QPixmap(filename).scaled(TILE_SIZE, TILE_SIZE), this)); img.data()->_items.last()->setVisible(false); } else { file_exists = false; } std::cout << "Looking for " << filename.toStdString() << " : " << file_exists<< std::endl; tile_id ++; } _pixmaps[(Direction)i] = img; } // Store default pixmap _current_pixmap = _pixmaps[BOTTOM]->_items[0]; _current_pixmap->setVisible(true); addToGroup(_current_pixmap); // Draw ellipsis on the bottom right of the perso _status = new QGraphicsEllipseItem(this); const int w = _current_pixmap->pixmap().size().width(); const int size_ellipse = w/4; _status->setRect(w-size_ellipse, w-size_ellipse, size_ellipse, size_ellipse); _status->setBrush(QBrush(Qt::green)); addToGroup(_status); // Box drawn when we select the perso _selected_item_box = new QGraphicsRectItem(QRectF(0., 0., boundingRect().width(), boundingRect().height()), this); _selected_item_box->setPen(QPen(QBrush(QColor(Qt::yellow)), 1)); _selected_item_box->setVisible(false); // Connect animation timer connect(&_move_timer, SIGNAL(timeout()), this, SLOT(updateAnimation())); // Connection between the graphical object and the data connect(_perso, SIGNAL(signal_set_has_moved(bool)), this, SLOT(slot_perso_has_move(bool))); // Connection between the graphical object and the data connect(_perso, SIGNAL(signal_perso_is_dead(Perso *)), this, SLOT(slot_perso_dead(Perso *))); }
void Container::update() { updateAnimation(); container->begin(); ofBackgroundGradient(70,120); ofDrawBitmapString("TEST CONTRAINER", ofGetWidth()/3, ofGetHeight()/2); container->end(); }
void UISlidingToolBar::sltParentGeometryChanged(const QRect &parentRect) { /* Update rectangle: */ m_parentRect = parentRect; /* Adjust geometry: */ adjustGeometry(); /* Update animation: */ updateAnimation(); }
/////////////////////////////////////////////////////////////////////////////////////////////////// // Update an entity (do animation, and change screen location) // Parameters: // c: Character to be updated // u8 updateCharacter(TCharacter *c) { TEntity *e = &c->entity; TPhysics *p = &e->phys; TAnimation *anim = &e->graph.anim; TAnimFrame *af = anim->frames[anim->frame_id]; u8 alive = 1; // Previous to calculations, next position is similar to current e->x = e->nx; e->y = e->ny; e->pscreen = e->npscreen; e->pw = af->width; e->ph = af->height; // Update animation. If changes sprite, then we should redraw if ( updateAnimation(&e->graph.anim, e->nAnim, e->nStatus) ) { e->draw = 1; // Redraw af = anim->frames[anim->frame_id]; // Get values of the new frame e->nAnim = 0; // No next animation/animstatus e->nStatus = as_null; } // Update physics and check collisions updateCharacterPhysics(c); applyCharacterBlockCollisions(c); // Maintain into limits if ( e->nx <= G_minX) { e->nx = G_minX + 1; p->x = e->nx * SCALE; } else if ( e->nx + af->width >= G_maxX ) { e->nx = G_maxX - af->width; p->x = e->nx * SCALE; } if ( e->ny + af->height >= G_maxY ) { e->ny = G_maxY - af->height; p->y = e->ny * SCALE; alive = 0; } else if ( e->ny <= G_minY ) { e->ny = G_minY + 1; p->y = e->ny * SCALE; } // Check if character has moved to calculate new location and set for drawing if ( e->ny != e->y ) { e->npscreen = cpct_getScreenPtr(CPCT_VMEM_START, e->nx, e->ny); e->draw = 1; } else if ( e->nx != e->x ) { e->npscreen = e->npscreen + e->nx - e->x; e->draw = 1; } return alive; }
void ofxAssimpModelLoader::setTime(float t){ // 0 - 1 if(getAnimationCount()){ // only evaluate if we have a delta t. if(animationTime != t){ animationTime = t; updateAnimation(currentAnimation, animationTime); } } }
void Menu::update(sf::RenderWindow* window) { if(m_timeSinceLastUpdate > m_duration + m_TimePerFrame) { updateAnimation(); } else { m_timeSinceLastUpdate += m_TimePerFrame; } }
HbRepeatIconItem::HbRepeatIconItem(const QString& name,QGraphicsItem *parent): HbWidgetBase(parent), mIcon(name), mMode(Qt::KeepAspectRatio), mMask(QPixmap()), mOffset(0), mRepeatPixmap(0), mConnected(false) { connect(&mTimer,SIGNAL(timeout()),this,SLOT(updateAnimation())); }
//------------------------------------------- void ofxAssimpModelLoader::setNormalizedTime(float t){ // 0 - 1 if(getAnimationCount()) { const aiAnimation* anim = scene->mAnimations[currentAnimation]; animationTime = ofMap(t, 0.0, 1.0, 0.0, (float)anim->mDuration, false); updateAnimation(currentAnimation, animationTime); } }
PhaseButton::PhaseButton(const QString &_name, QGraphicsItem *parent, QAction *_doubleClickAction, bool _highlightable) : QObject(), QGraphicsItem(parent), name(_name), active(false), highlightable(_highlightable), activeAnimationCounter(0), doubleClickAction(_doubleClickAction), width(50) { if (highlightable) { activeAnimationTimer = new QTimer(this); connect(activeAnimationTimer, SIGNAL(timeout()), this, SLOT(updateAnimation())); activeAnimationTimer->setSingleShot(false); } else activeAnimationCounter = 9.0; setCacheMode(DeviceCoordinateCache); }
void Player::update(float dt) { if (currentState == newState || isLockState()) { updateMovement(); } else { currentState = newState; updateAnimation(); } }
void UISlidingToolBar::prepareAnimation() { /* Prepare mdi-sub-window geometry animation itself: */ connect(this, SIGNAL(sigShown()), this, SIGNAL(sigExpand()), Qt::QueuedConnection); m_pAnimation = UIAnimation::installPropertyAnimation(this, "widgetGeometry", "startWidgetGeometry", "finalWidgetGeometry", SIGNAL(sigExpand()), SIGNAL(sigCollapse())); connect(m_pAnimation, SIGNAL(sigStateEnteredStart()), this, SLOT(sltMarkAsCollapsed())); connect(m_pAnimation, SIGNAL(sigStateEnteredFinal()), this, SLOT(sltMarkAsExpanded())); /* Update geometry animation: */ updateAnimation(); }
void Npc::updateCurrent(CommandQueue &command_queue, const sf::Time dt) { if (isActive()) { updateAnimation(dt); action_queue.update(dt); if (getCurrentDirection() == Direction::Left) goLeft(dt); else if (getCurrentDirection() == Direction::Right) goRight(dt); else if (getCurrentDirection() == Direction::Up) goUp(dt); else if (getCurrentDirection() == Direction::Down) goDown(dt); } }
void Jumper::CanopyOpening::update(float dt) { if( _canopy->getInflation() > 0 ) { updateAnimation( dt ); } if( _clump->getAnimationController()->isEndOfAnimation( 0 ) ) _endOfAction = true; // synchronize physics & render _clump->getFrame()->setMatrix( _matrixConversion->convert( wrap( _phActor->getGlobalPose() ) ) ); _clump->getFrame()->getLTM(); }
// experimental animation SidarAnimation::SidarAnimation(QObject *parent) : QObject(parent), onetime(false), label_h(0), label_w(0) { // init animation m_animation_object.text = "MOVTEX"; m_animation_object.tex_x = 0; m_animation_object.tex_y = 0; m_anim_tick.setInterval(300); connect(&m_anim_tick, SIGNAL(timeout()), this, SLOT(updateAnimation())); m_anim_tick.start(); }
void Player::updateDead(Game& game, Level& level) { if (playerAnimation != PlayerAnimation::Die1) { animation.currentTextureIdx = 0; setAnimation(PlayerAnimation::Die1); } if (animation.currentTextureIdx >= animation.textureIndexRange.second) { return; } updateAnimation(game); }
void AGENT::update(void) { // move if ((!group->is_single_unit() || state == AGENT::READY_FIGHT) && !group->is_building()) { update_move(); collision_check(); } // generic unit status check_health(); if (!has_not_moved()) clear_stuckcounter(); if (!build_data) updateAnimation(); }
void MainCharacter::update() { updateConstrols(); updateAnimation(); for (unsigned int i = 0; i < m_environment->getTrees().size(); i++) { if (m_player->isCollaiding( m_environment->getTrees()[i]->getTrunk()->GetCollision())) { std::cout << "koliduje kurna!" << std::endl; } } }
void Jumper::Pull::update(float dt) { updateAnimation( dt ); updateProceduralAnimation( dt ); // synchronize physics & render _clump->getFrame()->setMatrix( _matrixConversion->convert( wrap( _phActor->getGlobalPose() ) ) ); _clump->getFrame()->getLTM(); // update controls if( _pcInHand && _actionTime > _blendTime ) { updateBlending( dt ); } // pull pilot chute if( ( _actionTime - _blendTime >= FRAMETIME(1012) - FRAMETIME(1002) ) && !_pilotchute->isPulled() ) { _pilotchute->pull( Jumper::getLineHandJoint( _clump ) ); return; } if (_jumper->getSpinalCord()->phase || !_pilotchute->isPulled()) return; // drop pilot chute if( /*( _actionTime - _blendTime >= FRAMETIME(1022) - FRAMETIME(1002) ) &&*/ !_pilotchute->isDropped() ) { NxMat34 pose = _phActor->getGlobalPose(); NxVec3 x = pose.M.getColumn(0); NxVec3 y = pose.M.getColumn(1); NxVec3 z = pose.M.getColumn(2); _pilotchute->drop( z * 10.0f - x * 5.0f ); } // look for opening if( _pilotchute->isOpened() ) { _endOfAction = true; } engine::IAnimationController* animCtrl = _clump->getAnimationController(); if( animCtrl->isEndOfAnimation( 0 ) || _pilotchute->isDropped() ) { // blend to second animation track (put hands over head) float weight = animCtrl->getTrackWeight( 0 ); weight -= dt / trackBlendTime; if( weight < 0 ) weight = 0.0f; animCtrl->setTrackWeight( 0, weight ); animCtrl->setTrackWeight( 1, 1.0f - weight ); } }
void Effect::updateAnimation() { int animationPhase = (g_clock.ticks() - m_animationStartTicks) / TICKS_PER_FRAME; if(animationPhase < getAnimationPhases()) m_animation = animationPhase; if(animationPhase < getAnimationPhases() - 1) { auto self = asEffect(); g_dispatcher.scheduleEvent([self]() { self->updateAnimation(); }, TICKS_PER_FRAME); } }
Canvas::Canvas(QWidget *parent) : QWidget(parent), ui(new Ui::Canvas) { ui->setupUi(this); ui->controlPointInput->setValidator(new QIntValidator(0,20,this)); ui->grainInput->setValidator(new QIntValidator(0,100,this)); ui->editPointNum->setRange(1, input.control); input.update_grain(); animationTimer = new QTimer(this); connect( animationTimer,SIGNAL(timeout()), this, SLOT(updateAnimation()) ); car.position_x = input.grain_x[0]; car.position_y = input.grain_y[0]; }
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(); } }
AnimatedSprite::AnimatedSprite(std::string fileName, const MultiAnimationSteps &multisteps): _varray(sf::Quads, 4), _multiSteps(multisteps), _x(32), _y(32), _angle(0), _totalTime(sf::milliseconds(100)) { _textures.loadFromFile(fileName); auto framesSize = _textures.getSize(); unsigned int width = framesSize.x, height = framesSize.y; if (height != 64 || width%64) throw std::logic_error("Animation texture size is not correct."); // use first frame forever as default _currentSteps.push_back({0,sf::milliseconds(100)}); updateAnimation({}); updatePosition(); }
AnimatedSprite::AnimatedSprite(std::string fileName, const AnimationSteps &steps) : _varray(sf::Quads, 4), _x(32), _y(32), _angle(0), _currentSteps(steps) { _textures.loadFromFile(fileName); auto framesSize = _textures.getSize(); unsigned int width = framesSize.x, height = framesSize.y; if (height != 64 || width%64) throw std::logic_error("Animation texture size is not correct."); for (auto p : _currentSteps) _totalTime += p.second; updateAnimation({}); updatePosition(); }
void Fish::update(float dt){ if (!_outsideGameBounds) { setPosition(getPositionX() + (_velocity.x * dt), getPositionY() + (_velocity.y * dt)); if ((getPositionX() > (Director::getInstance()->getVisibleSize().width + 100) && _velocity.x > 0) || ((getPositionX() < -100) && _velocity.x < 0)) { _outsideGameBounds = true; } } updateAnimation(dt); }
void MovingBehavior::update(const sf::Time& frameTime) { if (!m_isCollisionTilt) { handleMovementInput(); sf::Vector2f nextPosition; m_mob->calculateNextPosition(frameTime, nextPosition); sf::Vector2f oldPosition = m_mob->getPosition(); checkCollisions(nextPosition); checkForCollisionTilt(oldPosition); } // update animation updateTime(m_fightAnimationTime, frameTime); updateAnimation(); }
/** * \fn bool WinOrNot(sInterface *p_interface, sMap *p_map) * \brief Fonction qui deduit si l'utilisateur a gagné ou non * * \param *p_interface pointeur vers une structure de type sInterface * \param *p_map pointeur vers une structure de type sMap * \return bool enum de type eBool vaut 1 si l'utilisateur a gagné 0 sinon */ bool WinOrNot(sInterface *p_interface, sMap *p_map) { if (comparePositionRect(getRealPosition(p_map->ending), p_interface->player.realPosition)) { Mix_PlayChannel(-1, p_interface->sonor.applause, 0); while (p_interface->effect.l_congrate->actualFrame != p_interface->effect.l_congrate->frameAmount - 1) { SDL_RenderCopy(p_interface->renderer, p_interface->backgroundSprite, NULL, NULL); updateAnimation(p_interface->effect.l_congrate, p_interface); SDL_RenderPresent(p_interface->renderer); SDL_Delay(100); } p_interface->effect.l_congrate->actualFrame = 0; SDL_Delay(1000); return TRUE; } return FALSE; }
void Rune::update(sf::RenderWindow* window) { if(m_timeSinceLastUpdate > m_duration + m_TimePerFrame) { updateAnimation(); } else { m_timeSinceLastUpdate += m_TimePerFrame; } if(!m_taken) { m_position = sf::Vector2f((m_posInWorld%(PATTERN_WIDTH*PATTERN_NBR)) * SPRITE_WIDTH,floor(m_posInWorld/(PATTERN_WIDTH*PATTERN_NBR))*SPRITE_HEIGHT); } else { m_position = sf::Vector2f(20.0f+(m_posOnHUD*(SPRITE_WIDTH+10)),980.0f); } m_sprite.setPosition(m_position); }
void Effect::start() { m_animationStartTicks = g_clock.ticks(); auto self = asEffect(); // schedule update if(getAnimationPhases() > 1) { g_dispatcher.scheduleEvent([self]() { self->updateAnimation(); }, TICKS_PER_FRAME); } // schedule removal g_dispatcher.scheduleEvent([self]() { g_map.removeThing(self); }, TICKS_PER_FRAME * getAnimationPhases()); }