Пример #1
0
void Player::logic()
{
    switch (mAction)
    {
        case STAND:
        case SIT:
        case DEAD:
        case HURT:
           break;

        case WALK:
            mFrame = (get_elapsed_time(mWalkTime) * 6) / getWalkSpeed();
            if (mFrame >= 6)
                nextStep();
            break;

        case ATTACK:
            int rotation = 0;
            std::string particleEffect = "";
            int frames = 4;

            if (mEquippedWeapon &&
                mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW)
            {
                frames = 5;
            }

            mFrame = (get_elapsed_time(mWalkTime) * frames) / mAttackSpeed;

            //attack particle effect
            if (mEquippedWeapon)
                particleEffect = mEquippedWeapon->getParticleEffect();

            if (!particleEffect.empty() && mParticleEffects && mFrame == 1)
            {
                switch (mDirection)
                {
                    case DOWN: rotation = 0; break;
                    case LEFT: rotation = 90; break;
                    case UP: rotation = 180; break;
                    case RIGHT: rotation = 270; break;
                    default: break;
                }
                Particle *p;
                p = particleEngine->addEffect("graphics/particles/" +
                                              particleEffect, 0, 0, rotation);
                controlParticle(p);
            }

            if (mFrame >= frames)
                nextStep();

            break;
    }

    Being::logic();
}
Пример #2
0
bool Chaser::write(QByteArray* universes)
{
	Q_UNUSED(universes);

	/* With some changes to scene, chaser could basically act as a
	   proxy for its members by calling the scene's write() functions
	   by itself instead of starting/stopping them. Whether this would do
	   any good is not clear. */

	/* TODO: One extra step is required in single shot mode to return
	   false and thus get a chaser removed from MasterTimer. Not a big
	   problem, but removing already after starting the last step would
	   improve performance (very) slightly. */

	if (m_elapsed == 0)
	{
		/* This is the first step since the last start() call */

		/* Get the next step index */
		nextStep();

		/* Start the current function */
		startMemberAt(m_runTimePosition);

		/* Mark one cycle being elapsed */
		m_elapsed = 1;
	}
	else if (m_elapsed >= Bus::instance()->value(m_busID) ||
		 m_tapped == true)
	{
		/* Reset tapped flag even if it wasn't true */
		m_tapped = false;

		/* Stop current function */
		stopMemberAt(m_runTimePosition);

		/* Get the next step index */
		nextStep();

		/* Check, whether we have gone a full cycle (thru all steps) */
		if (roundCheck() == false)
			return false;
		else
			startMemberAt(m_runTimePosition);

		/* Mark one cycle being elapsed since it tracks only the
		   duration of the current step. */
		m_elapsed = 1;
	}
	else
	{
		/* Just waiting for hold time to pass */
		m_elapsed++;
	}

	return true;
}
Пример #3
0
FaToDFA::FaToDFA(modes _mode, AlgorithmWidget* _algorithm_widget, FA_widget* _not_dfa_widget, FA_widget* _dfa_widget, QLabel* _var_widget, QObject* parrent)
 : Algorithm(parrent),  mode(_mode),  algorithm_widget(_algorithm_widget), not_dfa_widget(_not_dfa_widget), dfa_widget(_dfa_widget), var_widget(_var_widget)
{
    actInstruction = HEADER;
    prewInstruction = HEADER;
    instruction_count = WHILE_NEW+1;
    initInstructions();
    initBreakpoints(instruction_count);

    this->setColumnCount(1);
    this->setRowCount(instructions.count());

    var_widget->setText("");

    for(int i = 0; i < instructions.count();i++)
    {
        QModelIndex index = this->index(i,0,QModelIndex());
        setData(index,instructions[i],Qt::EditRole);
        setData(index,true,Algorithm::HasBreakpoint_Role);
        setData(index,false,Algorithm::Breakpoint_Role);
        switch(i)
        {
            case HEADER:
                setData(index,false,Algorithm::HasBreakpoint_Role);
                break;
        }
    }


    //
    // Connect algorithm buttons.
    //
    connect(this->algorithm_widget,SIGNAL(playPressed(int)),this,SLOT(runAlgorithm(int)));
    connect(this->algorithm_widget,SIGNAL(stopPressed()),this,SLOT(stop()));
    connect(this->algorithm_widget,SIGNAL(prewPressed()),this,SLOT(prevStep()));
    connect(this->algorithm_widget,SIGNAL(nextPressed()),this,SLOT(nextStep()));
    connect(this->algorithm_widget, SIGNAL(checkSolutionPressed()), this, SLOT(checkSolution()));
    connect(this->algorithm_widget, SIGNAL(showCorrectSolutionPressed()), this, SLOT(showCorrectSolution()));
    connect(this->algorithm_widget, SIGNAL(showUserSolutionPressed()), this, SLOT(showUserSolution()));
    connect(this->algorithm_widget, SIGNAL(beginPressed()), this, SLOT(toBegin()));
    connect(this->algorithm_widget, SIGNAL(endPressed()), this, SLOT(toEnd()));

    //
    // Connect timers.
    //
    connect(play_timer, SIGNAL(timeout()), this, SLOT(nextStep()));
    connect(check_step_timer, SIGNAL(timeout()), this, SLOT(checkSolution()));

    // Connect Finite Automata widgets
    connect(not_dfa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(setFA(FiniteAutomata*)));
    connect(dfa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(setDFA(FiniteAutomata*)));

    not_dfa_widget->setFA(new FiniteAutomata());

    algorithm_widget->enableShowButton();
}
Пример #4
0
void ModuleCoordinator::update(void) {
  //! \todo Two calls per update ? fix it
  //qDebug() << "Modules\n";
  emit updateModules();
  //qDebug() << "ModuleCoordinator emit nextStep";
  emit nextStep();
}
Пример #5
0
    bool compareDfaOrigins(const DfaStates& nfasWithInput, DfaVertex* dfa2p) {
	// Return true if the NFA nodes both DFAs came from are the same list
	// Assume there are no duplicates in either input list or NFAs under dfa2
	nextStep();
	// Mark all input vertexes
	int num1s = 0;
	for (DfaStates::const_iterator nfaIt=nfasWithInput.begin(); nfaIt!=nfasWithInput.end(); ++nfaIt) {
	    DfaVertex* nfaStatep = *nfaIt;
	    nfaStatep->user(m_step);
	    num1s++;
	}
	if (!num1s) v3fatalSrc("DFA node construction that contains no NFA states");

	// Check comparison; must all be marked
	// (Check all in dfa2p were in dfa1p)
	int num2s = 0;
	for (V3GraphEdge* dfaEdgep = dfa2p->outBeginp(); dfaEdgep; dfaEdgep=dfaEdgep->outNextp()) {
	    if (nfaState(dfaEdgep->top())) {
		if (dfaEdgep->top()->user() != m_step) return false;
		num2s++;
	    }
	}
	// If we saw all of the nodes, then they have the same number of hits
	// (Else something in dfa1p that wasn't in dfa2p)
	if (num1s != num2s) return false;
	// Match
	return true;
    }
void KisBasicMathToolbox::waveuntrans(KisMathToolbox::KisWavelet* wav, KisMathToolbox::KisWavelet* buff, uint halfsize)
{
    uint l = (2 * halfsize) * wav->depth * sizeof(float);
    for (uint i = 0; i < halfsize; i++) {
        float * itLL = wav->coeffs + i * buff->size * buff->depth;
        float * itHL = wav->coeffs + (i * buff->size + halfsize) * buff->depth;
        float * itLH = wav->coeffs + (halfsize + i) * buff->size * buff->depth;
        float * itHH = wav->coeffs + ((halfsize + i) * buff->size + halfsize) * buff->depth;
        float * itS11 = buff->coeffs + 2 * i * wav->size * wav->depth;
        float * itS12 = buff->coeffs + (2 * i * wav->size + 1) * wav->depth;
        float * itS21 = buff->coeffs + (2 * i + 1) * wav->size * wav->depth;
        float * itS22 = buff->coeffs + ((2 * i + 1) * wav->size + 1) * wav->depth;
        for (uint j = 0; j < halfsize; j++) {
            for (uint k = 0; k < wav->depth; k++) {
                *(itS11++) = (*itLL + *itHL + *itLH + *itHH) * 0.25 * M_SQRT2;
                *(itS12++) = (*itLL - *itHL + *itLH - *itHH) * 0.25 * M_SQRT2;
                *(itS21++) = (*itLL + *itHL - *itLH - *itHH) * 0.25 * M_SQRT2;
                *(itS22++) = (*(itLL++) - *(itHL++) - *(itLH++) + *(itHH++)) * 0.25 * M_SQRT2;
            }
            itS11 += wav->depth; itS12 += wav->depth;
            itS21 += wav->depth; itS22 += wav->depth;
        }
        emit nextStep();
    }
    for (uint i = 0; i < halfsize; i++) {
        uint p = i * wav->size * wav->depth;
        memcpy(wav->coeffs + p, buff->coeffs + p, l);
        p = (i + halfsize) * wav->size * wav->depth;
        memcpy(wav->coeffs + p, buff->coeffs + p, l);
    }

    if (halfsize != wav->size / 2) {
        waveuntrans(wav, buff, halfsize*2);
    }
}
Пример #7
0
void MainWindow::on_submitButton_clicked()
{
    try
    {
        bool ok=true;
        game.setBullsCows(ui->bullsNum->text().toInt(&ok), ui->cowsNum->text().toInt(&ok));
        if (!ok)
            throw COMPG_WRONG_BC_VALUES;
        LISTOUT(ui->mainLabel->text()+"  :  "+ui->bullsNum->text()+tr(" bulls, ")+
                ui->cowsNum->text()+tr(" cows."));
        ui->bullsNum->clear();
        ui->cowsNum->clear();
        ui->bullsNum->setFocus();
        nextStep();
    }
    catch (int e)
    {
        switch (e)
        {
        case COMPG_WRONG_BC_VALUES:
            LISTOUT(tr("Impossible number of bulls and cows. Try again."));
            break;
        }
    }
    ui->historyList->scrollToBottom();
}
/*
*				---Main---
*
* using goto statements for fun and profit
*/
int main(void)
{
	// Start TestCode execution
	TestMathematicalOperationsOfTwoComplexNumbers();
	TestTruncationOfComplexResultString();
	TestCBuildInTruncation();
	// End TestCode execution

	printf_s("Willkommen zum lustigen rechnen mit komplexen Zahlen!\n");  // start of the calculator -> welcome the user

	NewComplex:				// goto case 2
	getComplexNumbers();	// ask for user input of two complex numbers

	NextOperation:			// goto case 1
	showMenu();				// ask the user for the mathematical operation to be used on the complex numbers
				
	switch(nextStep())		// ask the user what has to be done afterwards
	{
	case '1':
		goto NextOperation;
	case '2':
		goto NewComplex;
	default: 
		goto Exit;
	}

	Exit:					// goto case 3
	printf_s("\n\nAuf Wiedersehen!");
	Sleep(2500);
	system(EXIT_SUCCESS);	// close the console
	return 0;				// exit the program
}
Пример #9
0
void JpegReceiver::mainProc()
{
	Capture_Log::getInstance()->enable();
	int connectionAttempts = 0;
	while (true)
	{
		DWORD res = ::WaitForSingleObject( event_abort, 0);
//		DWORD tm = GetTickCount();
		if (res == WAIT_OBJECT_0)
		{
			break;
		}
		if (!started)
		{
			connectToCamera();
			++connectionAttempts;
			if (connectionAttempts > maxConnectionAttempts) break;
		}
		if (started)
		{
			nextStep();
//			Sleep(20);
		}
//		Capture_Log::getInstance()->log_write("TCP time is %d\n", GetTickCount() - tm);
	}
	sock.reset();
}
Пример #10
0
		void nextStep(bool pFreeRun, long & pFreeStep)
		{
			if (pFreeRun)
				pFreeStep++;
			else
				nextStep();
		}
Пример #11
0
    virtual void process()
    {
        switch (m_runtime.currAnim)
        {
        case LedAnimation_On:
            if (m_runtime.prevAnim != LedAnimation_On)
            {
                m_runtime.pwm = m_runtime.pwm == 0 ? 255 : m_runtime.pwm;
                analogWrite(m_pin, m_runtime.pwm);
                m_runtime.prevAnim = LedAnimation_On;
            }
            break;
        case LedAnimation_Off:
            if (m_runtime.prevAnim != LedAnimation_Off)
            {
                analogWrite(m_pin, 0);
                m_runtime.prevAnim = LedAnimation_Off;
            }
            break;
        case LedAnimation_FadeIn:
            if (m_runtime.prevAnim != LedAnimation_FadeIn)
            {
                m_runtime.prevAnim = LedAnimation_FadeIn;
            }
            switch (currentStep()->info.factor)
            {
            case LedAnimationFactor_Quarter: m_runtime.pwm += 0.25; break;
            case LedAnimationFactor_Half: m_runtime.pwm += 0.5; break;
            case LedAnimationFactor_Once: m_runtime.pwm += 1.0; break;
            case LedAnimationFactor_Twice: m_runtime.pwm += 2.0; break;
            }
            analogWrite(m_pin, (int)m_runtime.pwm);
            break;
        case LedAnimation_FadeOut:
            if (m_runtime.prevAnim != LedAnimation_FadeOut)
            {
                m_runtime.prevAnim = LedAnimation_FadeOut;
            }
            switch (currentStep()->info.factor)
            {
            case LedAnimationFactor_Quarter: m_runtime.pwm -= 0.25; break;
            case LedAnimationFactor_Half: m_runtime.pwm -= 0.5; break;
            case LedAnimationFactor_Once: m_runtime.pwm -= 1.0; break;
            case LedAnimationFactor_Twice: m_runtime.pwm -= 2.0; break;
            }
            analogWrite(m_pin, (int)m_runtime.pwm);
            break;
        }
        if (isNextStep())
        {
            nextStep();
#ifdef _LED_PROCESSOR_DEBUG
            if (m_runtime.prevAnim != m_runtime.currAnim)
            {
                debug();
            }
#endif
        }
    }
void startAuto() {
	thisStepNum = 0; //ALWAYS SET THIS TO 0!
	if (runningStepNum == 0) { //if at the beginning
		resetAuto();
		//clear screen or beep or whatever
		nextStep();
	}
}
Пример #13
0
void HotStepper::setNextStep(){
  if(_remaining > 0 && !_paused){
    _remaining--;
    setStep(nextStep());
  }else{
    release();
  }
}
Пример #14
0
KBBTutorial::KBBTutorial(QWidget* parent) : QGroupBox(i18n("Tutorial"), parent)
{
	m_marker = 0;
	m_gameWidget = 0;

	setMinimumSize(QSize(WIDTH, WIDTH));
	setFixedWidth(WIDTH);

	QVBoxLayout *tutorialLayout = new QVBoxLayout();
	setLayout(tutorialLayout);
	setFlat(true);

	m_progression = new QProgressBar(this);
	m_progression->setTextVisible(true);
	m_progression->setFormat("%v / %m");
	m_progression->setMinimum(FIRST_STEP-1);
	m_progression->setMaximum(LAST_STEP);
	m_progression->setWhatsThis(i18n("Displays the progress of the tutorial."));
	tutorialLayout->addWidget(m_progression);

	m_title = new QLabel(this);
	tutorialLayout->addWidget(m_title, 0, Qt::AlignHCenter);

	m_explanation = new KTextEdit(this);
	m_explanation->setReadOnly(true);
	m_explanation->setFrameStyle(QFrame::NoFrame);
	m_explanation->setAlignment(Qt::AlignJustify);
	tutorialLayout->addWidget(m_explanation);

	tutorialLayout->addStretch();


	QHBoxLayout *actionLayout = new QHBoxLayout();
	tutorialLayout->addLayout(actionLayout);
	QLabel* iconLabel = new QLabel(this);
	iconLabel->setFixedSize(24, 24);
	iconLabel->setPixmap(KIcon( QLatin1String( "go-next" )).pixmap(24, 24));
	actionLayout->addWidget(iconLabel, 0, Qt::AlignVCenter);
	m_playerAction = new QLabel(this);
	m_playerAction->setWhatsThis(i18n("Describes what you should do to reach the next tutorial step."));
	m_playerAction->setAlignment(Qt::AlignLeft);
	m_playerAction->setWordWrap(true);
	m_playerAction->setFrameStyle(QFrame::StyledPanel);
	m_playerAction->setStyleSheet("border-style: none");
	actionLayout->addWidget(m_playerAction, 0, Qt::AlignVCenter);

	QHBoxLayout *buttonLayout = new QHBoxLayout();
	tutorialLayout->addLayout(buttonLayout);
	m_buttonPrevious = new KPushButton(KIcon( QLatin1String( "go-previous") ), i18nc("Previous tutorial step", "&Previous"), this);
	m_buttonPrevious->setWhatsThis(i18n("Go back to the previous tutorial step."));
	connect(m_buttonPrevious, SIGNAL(clicked()), this, SLOT(previousStep()));
	buttonLayout->addWidget(m_buttonPrevious);
	m_buttonNext = new KPushButton(KIcon( QLatin1String( "go-next")) , i18nc("Next tutorial step", "&Next"), this);
	m_buttonNext->setWhatsThis(i18n("Go to the next tutorial step."));
	connect(m_buttonNext, SIGNAL(clicked()), this, SLOT(nextStep()));
	m_buttonNext->setDefault(true);
	buttonLayout->addWidget(m_buttonNext);
}
Пример #15
0
void effectFlame(struct Animate *a) {
	int yellow[3] = {255, rand() % 51 + 75, rand() % 10 + 1};
	int red = rand() % 16 + 240;

	if (a->open) {
		setAnimate(a, (yellow[0] + red) / 2, yellow[1], yellow[2], 0, 15);
	}
	nextStep(a);
}
Пример #16
0
void Tutorial::nextStep(const QString& id) {
    if (!d->mSteps.contains(id)) {
        kError(debugArea()) << "No step" << id << "found in tutorial"
                            << d->mTutorialInformation->id();
        return;
    }

    nextStep(d->mSteps.value(id));
}
Пример #17
0
void run() {
	/* BEGIN SOLUTION */
	int cpt=0;
	do {
		writeMessage(int2str(cpt));
		nextStep();
		cpt++;
	} while (!endingPosition());
	writeMessage(int2str(cpt));
}
Пример #18
0
void MainWindow::createView()
{
	_view = new View(this);
	setCentralWidget(_view);

	_model = new NetModel(this);
	_model->setSceneRect(0, 0, 500, 500);
	_view->setScene(_model);
	connect(&_timer, SIGNAL(timeout()), _model, SLOT(nextStep()));
}
Пример #19
0
void Robot::moveOneStep()
{
    //Get the next step and set the position.
    setPos(nextStep());
    //If this robot has a guardian line, change the toP1Distance.
    if(m_hasGuardianLine)
    {
        m_toP1Distance+=m_movingSpeed;
    }
}
Пример #20
0
bool Shuffle::write(QByteArray* universes)
{
	Q_UNUSED(universes);

	/* TODO: With some changes to scene, shuffle could basically act as a
	   proxy for its members by calling the scene's write() functions
	   by itself instead of starting/stopping them. Whether this would do
	   any good, is not clear. */

	if (m_elapsed == 0)
	{
		/* Get the next step index */
		nextStep();

		/* Start the current function */
		startMemberAt(m_runTimePosition);

		/* Mark one cycle being elapsed */
		m_elapsed = 1;
	}
	else if (m_elapsed >= Bus::instance()->value(m_busID))
	{
		/* Stop current function */
		stopMemberAt(m_runTimePosition);

		/* Get the next step index */
		nextStep();

		/* Start the next step immediately */
		startMemberAt(m_runTimePosition);

		/* Mark one cycle being elapsed */
		m_elapsed = 1;
	}
	else
	{
		/* Just waiting for hold time to pass */
		m_elapsed++;
	}

	return true;
}
Пример #21
0
void Tutorial::start() {
    setup();

    if (!d->mSteps.contains("start")) {
        kError(debugArea()) << "No start step found in tutorial"
                            << d->mTutorialInformation->id();
        finish();
        return;
    }

    nextStep("start");
}
// ------------ Switching and setting current rows
SUMOTime
MSAgentbasedTrafficLightLogic::trySwitch(bool) throw() {
    assert(getCurrentPhaseDef().minDuration >=0);
    assert(getCurrentPhaseDef().minDuration <= getCurrentPhaseDef().duration);
    if (myPhases[myStep]->isGreenPhase()) {
        // collects the data for the signal control
        collectData();
        // decides wheter greentime shall distributed between phases
        if (tDecide <= tSinceLastDecision) {
            calculateDuration();
        }
    }
    // increment the index to the current phase
    nextStep();
    // set the next event
    while (getCurrentPhaseDef().duration==0) {
        nextStep();
    }
    assert(myPhases.size()>myStep);
    return getCurrentPhaseDef().duration;
}
Пример #23
0
void Monster::logic()
{
    if (mAction != STAND)
    {
        mFrame = (get_elapsed_time(mWalkTime) * 4) / getWalkSpeed();

        if (mFrame >= 4 && mAction != DEAD)
            nextStep();
    }

    Being::logic();
}
Пример #24
0
StepPoints CAlgorithmParabola::getDrawPoints()
{
    reset();
    StepPoints points;
    StepPoints stepPoints;
    while(nextStep())
    {
        stepPoints = getStepDrawPoint();
        ADD_STEP_POINTS(stepPoints,points);
    }
    return points;
}
Пример #25
0
void
Nlsrc::runNextStep()
{
    if (m_fetchSteps.empty()) {
        return;
    }

    std::function<void()> nextStep = m_fetchSteps.front();
    m_fetchSteps.pop_front();

    nextStep();
}
Пример #26
0
void Being::setPath(const Path &path)
{
    mPath = path;
#ifdef TMWSERV_SUPPORT
    std::cout << this << " New path: " << path << std::endl;
#else
    if (mAction != WALK && mAction != DEAD)
    {
        nextStep();
        mWalkTime = tick_time;
    }
#endif
}
Пример #27
0
StepPoints CAlgorithmBresenham::getDrawPoints()
{
    reset();
    StepPoints points;
    StepPoints stepPoints;
    while(nextStep())
    {
        stepPoints = getStepDrawPoint();
        ADD_STEP_POINTS(stepPoints,points);
        //for(int i=0;i<stepPoints.size();i++) points.push_back(stepPoints.at(i));
    }
    return points;
}
Пример #28
0
int main_window::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: nextStep(); break;
        default: ;
        }
        _id -= 1;
    }
    return _id;
}
Пример #29
0
bool KBBTutorial::mayShootRay(const int incomingPosition)
{
	if (m_step==LAST_STEP)
		return true;
	else
		if (incomingPosition==m_laserToUse) {
			nextStep();
			return true;
		} else {
			// Highlight m_playerAction to show what the player has to do
			m_playerAction->setStyleSheet("color: black; background-color: #de0000");
			QTimer::singleShot(HIGHLIGHT_TIME, this, SLOT(restoreStyle()));
			return false;
		}
}
Пример #30
0
void GuideManager::handleEvent(cocos2d::EventCustom* event)
{
    void* userdata = event->getUserData();
    if (userdata)
    {
        setParent((Node*)userdata);
    }
    
    if (event->getEventName() == GUIDE_EVENT_TOUCH_IN_RECT)
    {
        nextStep(getNextStepId());
    }
    else if (event->getEventName() == GUIDE_EVENT_BEGIN_GUIDE)
    {
        nextStep(0); // test here
    }
    else if (event->getEventName() == GUIDE_EVENT_CONTENUE)
    {
        setWait(false);
        nextStep(getNextStepId());
    }
    else
    {}
}