BoxGroup::BoxGroup() { setFlags(QGraphicsItem::ItemIsFocusable); // 保存变换矩阵,当BoxGroup进行旋转后,可以使用它来进行恢复 oldTransform = transform(); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(moveOneStep())); currentShape = RandomShape; }
bool StepperMotor::moveOneStepBackward() { if (!interrupt) { stepIdx = incrementStep(stepIdx); moveOneStep(NUMBER_OF_STEPS - stepIdx - 1); } return interrupt; }
bool StepperMotor::moveOneStepForward() { if (!interrupt) { stepIdx = incrementStep(stepIdx); moveOneStep(stepIdx); } return interrupt; }
void ControllerSimpleMove::checkMoveUpdate( float delta ) { if(m_isMoving) { m_fMoveTimeCount += delta * 1000; if(m_fMoveTimeCount >= m_MoveSpan) {//计时器,每帧加delta*1000,如果大于设定的移动时间间隔,则将计时器置零,然后moveonesetp,应该是移动一步 m_fMoveTimeCount = 0; moveOneStep(); } } }
void ControllerSimpleMove::checkMoveUpdate( float delta ) { if(m_isMoving) { m_fMoveTimeCount += delta * 1000; if(m_fMoveTimeCount >= m_MoveSpan) { m_fMoveTimeCount = 0; moveOneStep(); } } }
void Colony::moveAnts() { double oldTime = omp_get_wtime(); static unsigned int step = 0; //moveUntilAllDead(); moveOneStep(); printDebugImage(); double newTime = omp_get_wtime(); std::cout << "step " << ++step << " in " << newTime - oldTime << "seconds\n"; }
void SGSHero::onMoveTo(SGMessage* message) { int x, y; message->getInt("x", &x); message->getInt("y", &y); SGSPoint target_pos(x,y); SGSPointList& path = __terrain->calcShortestPath(this, target_pos); if (path.empty()) { log("Failed to find available path"); return; } else { path.erase(path.begin()); } moveOneStep(&path); }
HeroReal::HeroReal(int role, int id, const QString &name, int x, int y, int healthPercentage, int magicPercentage): Hero(role, id, name, x, y, healthPercentage, magicPercentage) { //define attributes according to roles if (role == PLAYER_ROLE_MAGE) { _totalHealth = 800; _totalMagic = 2000; } else if (role == PLAYER_ROLE_PRIEST) { _totalHealth = 1200; _totalMagic = 1500; } else if (role == PLAYER_ROLE_WORRIOR) { _totalHealth = 2000; _totalMagic = 800; } this->_healthValue = healthPercentage * _totalHealth / 100; this->_magicValue = magicPercentage * _totalMagic / 100; QObject::connect(this, SIGNAL(needToMove()), this, SLOT(moveOneStep())); _sword = false; _armor = false; _boot = false; _isAlive = true; _isPaused = false; _magicAutoIncreaseTimer = new QTimer(); _magicAutoIncreaseTimer->setInterval(1000); QObject::connect(_magicAutoIncreaseTimer, SIGNAL(timeout()), this, SLOT(magicAutoIncrease())); _magicAutoIncreaseTimer->start(); }
void SGSHero::moveOneStepFinished(Node* node, void* ptr) { SGSPointList* path = reinterpret_cast<SGSPointList*>(ptr); moveOneStep(path); }