void AIStateBattleSphereGuard::update(float time) { if (myOwner->hasTarget && myOwner->targetEntry->inView) { myOwner->stateMachine->changeState(new AIStateBattleSphereCombat()); return; } if (myOwner->movementController->getMoveToTargetFailed()) { newTarget(); //game.gameConsole->addMessage("new guard target"); } else { timeUntilTargetChange -= time; if (timeUntilTargetChange <= 0) { newTarget(); //game.gameConsole->addMessage("new guard target"); } } if (myOwner->hasTarget && (myOwner->movementController->velocity.squaredLength() <= MOVING_THRESHOLD)) { // try to face the target Vector3 lookAtPos = myOwner->targetEntry->getPerceptedPosition(myOwner->target) + (myOwner->targetEntry->lastPerceptedVelocity.normalisedCopy() * 30.0f); Vector3 tempHeading = (lookAtPos - myOwner->movementController->currentPos).normalisedCopy(); if (!tempHeading.isZeroLength()) myOwner->desiredHeading = tempHeading; } }
bool CannonField::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: setAngle((int)static_QUType_int.get(_o+1)); break; case 1: setForce((int)static_QUType_int.get(_o+1)); break; case 2: shoot(); break; case 3: newTarget(); break; case 4: setGameOver(); break; case 5: restartGame(); break; case 6: moveShot(); break; default: return QWidget::qt_invoke( _id, _o ); } return TRUE; }
void Weapon::aimAt(const Math::Vec3& target) { if (target == Math::Vec3::ZERO) { return; } Math::Vec3 newTarget(target); if (newTarget.normalize() == this->target.normalize()) { return; } float deltaAngle = acosf(this->target.dot(newTarget)) * 180.0f / M_PI; if (isnan(deltaAngle)) { return; } Math::Vec3 normal = this->target.cross(newTarget); float signCorrection = (normal.get(Math::Vec3::Z) < 0.0f) ? -1.0f : 1.0f; float targetSignCorrection = (newTarget.get(Math::Vec3::X) < 0.0f) ? -1.0f : 1.0f; float newAngle = this->viewAngle + deltaAngle * signCorrection; float shear = (cosf(newAngle * M_PI / 180.0f) < 0.0f) ? 1.0f : 0.0f; this->viewAngle = newAngle; this->roll(newAngle); this->sprite->shearX(shear, 2); this->sprite->shearY(-0.15f * targetSignCorrection, 1); this->target = target; }
void TestEnv::mousePressEvent(QMouseEvent *event) { if (!started) { QWidget(event); } else { if (curTarget->contains(event->pos())) { emit TestEnv::emitHit(--remainingTargets); if (remainingTargets == 0) { TestEnv::stop(); } else { newTarget(); update(); } } else { emit TestEnv::emitError(++errors); } } }
void QmlAnchorBindingProxy::setTopTarget(const QString &target) { if (m_ignoreQml) return; QmlItemNode newTarget(targetIdToNode(target)); if (newTarget == m_topTarget) return; if (!newTarget.isValid()) return; RewriterTransaction transaction = beginRewriterTransaction( QByteArrayLiteral("QmlAnchorBindingProxy::setTopTarget")); m_topTarget = newTarget; setDefaultRelativeTopTarget(); anchorTop(); emit topTargetChanged(); }
b2Vec2 Enemy::pursue(b2Vec2 target, b2Vec2 tVel, float dist) { b2Vec2 between = target - getPosition(); float distance = between.Length(); float speed = body_->GetLinearVelocity().Length(); int maxTimePrediction = 1000; int timePrediction = 1000; b2Vec2 steer(0, 0); if (speed <= distance / maxTimePrediction) { timePrediction = maxTimePrediction; steer = arrive(target, dist); } else { timePrediction = distance / speed; b2Vec2 newTarget(tVel); newTarget *= timePrediction; newTarget += target; steer = arrive(newTarget, dist); } return steer; }
void HuntApp::appInit(){ gettimeofday(&tstart, NULL); gettimeofday(&now, NULL); secs = 0; newTarget(); chosen_btn=-1; }
void ScatteredLineBrush::BrushMove(const Point source, const Point target) { ImpressionistDoc* pDoc = GetDocument(); ImpressionistUI* dlg = pDoc->m_pUI; if (pDoc == NULL) { printf("PointBrush::BrushMove document is NULL\n"); return; } int lineAmount = 4; int size = pDoc->getSize(); for (int i = 0; i < lineAmount; i++) { // Get random numbers to set scatter location in the brush area int randomX = rand() % size + (-size / 2); int randomY = rand() % size + (-size / 2); // We need to set a new Point source for the brush as well to // match the location of the source and the target point Point newSource(source.x + randomX, source.y + randomY); Point newTarget(target.x + randomX, target.y + randomY); LineBrush::BrushMove(newSource, newTarget); } }
void Friend::newAction(){ int action = rand() % 4; if(action == 0){ newTarget(); }else{ newRotation(); } }
void ConvolveMatrixEffectConfigWidget::targetChanged(int) { if (!m_effect) { return; } QPoint newTarget(m_targetX->value() - 1, m_targetY->value() - 1); QPoint oldTarget = m_effect->target(); if (newTarget != oldTarget) { m_effect->setTarget(newTarget); emit filterChanged(); } }
CannonField::CannonField(QWidget *parent) : QWidget(parent) { currentAngle = 45; currentForce = 0; timerCount = 0; autoShootTimer = new QTimer(this); connect(autoShootTimer, SIGNAL(timeout()), this, SLOT(moveShot())); shootAngle = 0; shootForce = 0; setPalette(QPalette(QColor(250, 250, 200))); setAutoFillBackground(true); newTarget(); }
void QmlAnchorBindingProxy::setRightTarget(const QVariant &target) { QmlItemNode newTarget(target.value<ModelNode>()); if (newTarget == m_rightTarget) return; RewriterTransaction transaction = m_fxItemNode.modelNode().view()->beginRewriterTransaction(); m_rightTarget = newTarget; calcRightMargin(); emit rightTargetChanged(); }
void QmlAnchorBindingProxy::setHorizontalTarget(const QVariant &target) { QmlItemNode newTarget(target.value<ModelNode>()); if (newTarget == m_horizontalTarget) return; RewriterTransaction transaction = m_fxItemNode.modelNode().view()->beginRewriterTransaction(); m_horizontalTarget = newTarget; m_fxItemNode.anchors().setAnchor(AnchorLine::HorizontalCenter, m_horizontalTarget, AnchorLine::HorizontalCenter); emit horizontalTargetChanged(); }
void Ghost::updateEvent(double secsElapsed) { if (!mTarget) newTarget(); //check if we caught them if (mTarget && distanceSq(pos(), mTarget->pos()) < 9.0) { mTarget->remove(); Ghost* victim = new Ghost(mTarget->pos(), world()); victim->setVelocity(mTarget->velocity()); ++mKillCount; if (mKillCount % 3 == 0) new DormantGhostPortal(pos(), world()); newTarget(); } newTargetTimer += secsElapsed; if (newTargetTimer > 30) newTarget(); assert(mTarget || !(mPursue->isOn())); Actor::updateEvent(secsElapsed); }
Error BaseCompiler::_newLabel(Label* dst) { dst->_init_packed_op_sz_b0_b1_id(kOperandTypeLabel, 0, 0, 0, kInvalidValue); dst->_init_packed_d2_d3(0, 0); TargetNode* node = newTarget(); if (node == NULL) goto _NoMemory; dst->_label.id = node->getLabelId(); return kErrorOk; _NoMemory: return setError(kErrorNoHeapMemory); }
CannonField::CannonField( QWidget *parent, const char *name ) : QWidget( parent, name ) { ang = 45; f = 0; timerCount = 0; autoShootTimer = new QTimer( this, "movement handler" ); connect( autoShootTimer, SIGNAL(timeout()), this, SLOT(moveShot()) ); shoot_ang = 0; shoot_f = 0; target = QPoint( 0, 0 ); setPalette( QPalette( QColor( 250, 250, 200) ) ); newTarget(); }
void TestEnv::start() { distance = 0; positionList->clear(); mousePositionList->clear(); totalTime=0; errors=0; remainingTargets = totalTargets; newTarget(); started = true; emit emitHit(totalTargets); timer->start(); distTimer->start(50); update(); }
void HuntApp::appBtnDown(int button){ if (chosen_btn == -1 && !(button == 2 || button == 5)){ chosen_btn = button; } if (button == chosen_btn){ int nx,ny,nz; nx = x/(bs+1); ny = y/(bs+1); nz = z/(bs+1); if (nx == target[0] && ny == target[1] && nz == target[2]){ hlog.log(correct); newTarget(); } else { hlog.log(incorrect); } } }
void QmlAnchorBindingProxy::setHorizontalTarget(const QString &target) { if (m_ignoreQml) return; QmlItemNode newTarget(targetIdToNode(target)); if (newTarget == m_horizontalTarget) return; if (!newTarget.isValid()) return; RewriterTransaction transaction = beginRewriterTransaction( QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalTarget")); m_horizontalTarget = newTarget; anchorHorizontal(); emit horizontalTargetChanged(); }
Ghost::Ghost(Math::Point pos, Pointer<Entity> parent, QString name) : Actor(parent, name), mKillCount(0) { subclass(); setPos(pos); setMaxSpeed(9.0); mPursue = new Pursue(pointer()); mWander = new Wander(pointer()); addSteeringBehavior(mPursue); addSteeringBehavior(mWander); PersonView* view = new PersonView(pointer(), Qt::green); //view->setColor(Qt::green); // HULK SMASH! -- 20070108 iank setView(view); setVisible(true); newTarget(); }
void ScatteredPointBrush::BrushMove(const Point source, const Point target) { ImpressionistDoc* pDoc = GetDocument(); ImpressionistUI* dlg = pDoc->m_pUI; if (pDoc == NULL) { printf("PointBrush::BrushMove document is NULL\n"); return; } int size = pDoc->getSize(); //set random target coordinates //srand(time(NULL)); int numOfPoints = rand() % (size/2)*(size/2) + 1; for (int i = 0; i < numOfPoints; i++){ int xDisplacement = rand() % size; int yDisplacement = rand() % size; Point newSource(source.x + xDisplacement, source.y + yDisplacement); Point newTarget(target.x + xDisplacement, target.y + yDisplacement); PointBrush::BrushMove(newSource, newTarget); } }
static void findMakeTags (void) { stringList *identifiers = stringListNew (); boolean newline = TRUE; boolean in_define = FALSE; boolean in_rule = FALSE; boolean variable_possible = TRUE; int c; while ((c = nextChar ()) != EOF) { if (newline) { if (in_rule) { if (c == '\t' || (c = skipToNonWhite (c)) == '#') { skipLine (); /* skip rule or comment */ c = nextChar (); } else if (c != '\n') in_rule = FALSE; } stringListClear (identifiers); variable_possible = (boolean)(!in_rule); newline = FALSE; } if (c == '\n') newline = TRUE; else if (isspace (c)) continue; else if (c == '#') skipLine (); else if (variable_possible && c == '?') { c = nextChar (); ungetcToInputFile (c); variable_possible = (c == '='); } else if (variable_possible && c == ':' && stringListCount (identifiers) > 0) { c = nextChar (); ungetcToInputFile (c); if (c != '=') { unsigned int i; for (i = 0; i < stringListCount (identifiers); i++) newTarget (stringListItem (identifiers, i)); stringListClear (identifiers); in_rule = TRUE; } } else if (variable_possible && c == '=' && stringListCount (identifiers) == 1) { newMacro (stringListItem (identifiers, 0)); skipLine (); in_rule = FALSE; } else if (variable_possible && isIdentifier (c)) { vString *name = vStringNew (); readIdentifier (c, name); stringListAdd (identifiers, name); if (stringListCount (identifiers) == 1) { if (in_define && ! strcmp (vStringValue (name), "endef")) in_define = FALSE; else if (in_define) skipLine (); else if (! strcmp (vStringValue (name), "define")) { in_define = TRUE; c = skipToNonWhite (nextChar ()); vStringClear (name); /* all remaining characters on the line are the name -- even spaces */ while (c != EOF && c != '\n') { vStringPut (name, c); c = nextChar (); } if (c == '\n') ungetcToInputFile (c); vStringTerminate (name); vStringStripTrailing (name); newMacro (name); } else if (! strcmp (vStringValue (name), "export")) stringListClear (identifiers); else if (! strcmp (vStringValue (name), "include") || ! strcmp (vStringValue (name), "sinclude") || ! strcmp (vStringValue (name), "-include")) { boolean optional = (vStringValue (name)[0] == 'i')? FALSE: TRUE; while (1) { c = skipToNonWhite (nextChar ()); readIdentifier (c, name); vStringStripTrailing (name); if (isAcceptableAsInclude(name)) newInclude (name, optional); /* non-space characters after readIdentifier() may * be rejected by the function: * e.g. * include $* * * Here, remove such characters from input stream. */ do c = nextChar (); while (c != EOF && c != '\n' && (!isspace (c))); if (c == '\n') ungetcToInputFile (c); if (c == EOF || c == '\n') break; } } } } else variable_possible = FALSE; } stringListDelete (identifiers); }
bool BatchProcessImagesDialog::startProcess() { if (m_convertStatus == STOP_PROCESS) { endProcess(); return true; } QString targetAlbum = m_ui->m_destinationUrl->url().path(); //TODO check if it is valid also for remote URL's // this is a workarond for bug 117397 QFileInfo dirInfo(targetAlbum + '/'); if (!dirInfo.isDir() || !dirInfo.isWritable()) { KMessageBox::error(this, i18n("You must specify a writable path for your output file.")); endProcess(); return true; } BatchProcessImagesItem* item = static_cast<BatchProcessImagesItem*>(**m_listFile2Process_iterator); m_listFiles->setCurrentItem(item); // Lock current item into KIPI host application KPFileReadLocker(iface(), item->pathSrc()); if (prepareStartProcess(item, targetAlbum) == false) // If there is a problem during the { // preparation -> pass to the next item! ++*m_listFile2Process_iterator; ++m_progressStatus; m_ui->m_progress->setValue((int)((float)m_progressStatus *(float)100 / (float)m_nbItem)); item = static_cast<BatchProcessImagesItem*>(**m_listFile2Process_iterator); m_listFiles->setCurrentItem(item); if (**m_listFile2Process_iterator) { startProcess(); return true; } else { endProcess(); return true; } } KUrl desturl(targetAlbum + '/' + item->nameDest()); if (KIO::NetAccess::exists(desturl, KIO::NetAccess::DestinationSide, kapp->activeWindow()) == true) { switch (overwriteMode()) { case OVERWRITE_ASK: { int ValRet = KMessageBox::warningYesNoCancel(this, i18n("The destination file \"%1\" already exists;\n" "do you want overwrite it?", item->nameDest()), i18n("Overwrite Destination Image File"), KStandardGuiItem::cont()); if (ValRet == KMessageBox::No) { item->changeResult(i18n("Skipped.")); item->changeError(i18n("destination image file already exists (skipped by user).")); ++*m_listFile2Process_iterator; ++m_progressStatus; m_ui->m_progress->setValue((int)((float)m_progressStatus *(float)100 / (float)m_nbItem)); if (**m_listFile2Process_iterator) { startProcess(); return true; } else { endProcess(); return true; } } else if (ValRet == KMessageBox::Cancel) { processAborted(false); return false; } else { item->setDidOverWrite(true); } break; } case OVERWRITE_RENAME: { QFileInfo Target(targetAlbum + '/' + item->nameDest()); QString newFileName = RenameTargetImageFile(&Target); if (newFileName.isNull()) { item->changeResult(i18nc("batch process result", "Failed.")); item->changeError(i18n("destination image file already exists and cannot be renamed.")); ++*m_listFile2Process_iterator; ++m_progressStatus; m_ui->m_progress->setValue((int)((float)m_progressStatus *(float)100 / (float)m_nbItem)); if (**m_listFile2Process_iterator) { startProcess(); return true; } else { endProcess(); return true; } } else { QFileInfo newTarget(newFileName); item->changeNameDest(newTarget.fileName()); } break; } case OVERWRITE_SKIP: { item->changeResult(i18n("Skipped.")); item->changeError(i18n("destination image file already exists (skipped automatically).")); ++*m_listFile2Process_iterator; ++m_progressStatus; m_ui->m_progress->setValue((int)((float)m_progressStatus *(float)100 / (float)m_nbItem)); if (**m_listFile2Process_iterator) { startProcess(); return true; } else { endProcess(); return true; } break; } case OVERWRITE_OVER: // In this case do nothing : 'convert' default mode... item->setDidOverWrite(true); break; default: { endProcess(); return true; } } } m_ProcessusProc = new KProcess(this); m_ProcessusProc->setOutputChannelMode(KProcess::MergedChannels); initProcess(m_ProcessusProc, item, targetAlbum); m_commandLine = m_ProcessusProc->program().join(" "); item->changeOutputMess(m_commandLine + "\n\n"); connect(m_ProcessusProc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotFinished())); connect(m_ProcessusProc, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); m_ProcessusProc->start(); if (!m_ProcessusProc->waitForStarted()) { KMessageBox::error(this, i18n("Cannot start 'convert' program from 'ImageMagick' package;\n" "please check your installation.")); delete m_ProcessusProc; m_ProcessusProc = 0; return false; } return true; }
static void findMakeTags (void) { stringList *identifiers = stringListNew (); boolean newline = TRUE; boolean in_define = FALSE; boolean in_rule = FALSE; boolean variable_possible = TRUE; int c; while ((c = nextChar ()) != EOF) { if (newline) { if (in_rule) { if (c == '\t' || (c = skipToNonWhite (c)) == '#') { skipLine (); /* skip rule or comment */ c = nextChar (); } else if (c != '\n') in_rule = FALSE; } stringListClear (identifiers); variable_possible = (boolean)(!in_rule); newline = FALSE; } if (c == '\n') newline = TRUE; else if (isspace (c)) continue; else if (c == '#') skipLine (); else if (variable_possible && c == '?') { c = nextChar (); fileUngetc (c); variable_possible = (c == '='); } else if (variable_possible && c == ':' && stringListCount (identifiers) > 0) { c = nextChar (); fileUngetc (c); if (c != '=') { unsigned int i; for (i = 0; i < stringListCount (identifiers); i++) newTarget (stringListItem (identifiers, i)); stringListClear (identifiers); in_rule = TRUE; } } else if (variable_possible && c == '=' && stringListCount (identifiers) == 1) { newMacro (stringListItem (identifiers, 0)); skipLine (); in_rule = FALSE; } else if (variable_possible && isIdentifier (c)) { vString *name = vStringNew (); readIdentifier (c, name); stringListAdd (identifiers, name); if (stringListCount (identifiers) == 1) { if (in_define && ! strcmp (vStringValue (name), "endef")) in_define = FALSE; else if (in_define) skipLine (); else if (! strcmp (vStringValue (name), "define")) { in_define = TRUE; c = skipToNonWhite (nextChar ()); vStringClear (name); /* all remaining characters on the line are the name -- even spaces */ while (c != EOF && c != '\n') { vStringPut (name, c); c = nextChar (); } if (c == '\n') fileUngetc (c); vStringTerminate (name); vStringStripTrailing (name); newMacro (name); } else if (! strcmp (vStringValue (name), "export")) stringListClear (identifiers); } } else variable_possible = FALSE; } stringListDelete (identifiers); }
TargetNode* BaseCompiler::addTarget() { TargetNode* node = newTarget(); if (node == NULL) return NULL; return static_cast<TargetNode*>(addNode(node)); }