Exemplo n.º 1
0
void updatePlayer(Input *input)
{
    /* On rajoute un timer au cas où notre héros mourrait
    Si le timer vaut 0, c'est que tout va bien, sinon, on le décrémente jusqu'à 0, et là,
    on réinitialise.
    C'est pour ça qu'on ne gère le joueur que si ce timer vaut 0. */
    if(player.timerMort == 0)
    {
        if(!player.touch) // S'il n'est pas touché
        {
            /* On gère le timer de l'invincibilité */
            if(player.invincibleTimer > 0) player.invincibleTimer--;

            /* On réinitialise notre vecteur de déplacement latéral (X), pour éviter que le perso
            ne fonce de plus en plus */
            player.dirX = player.dirY = player.isAttacking = 0;

            attackManagement(input, &player);

            if(player.state < ATTACK_HORIZONTAL && input->puched < 3) playerDir(input, &player);

            /* Si on n'appuie sur rien, on charge l'animation marquant l'inactivité (Idle), je n'ai pas regarder encore si je pouvais l'optimiser */
            playerIdle(input, &player);

            resetInput(input);
        }
        /* Sinon si il est touché */
        else if(player.touch)
            entityTouch();

        /* On rajoute notre fonction de détection des collisions qui va mettre à
        jour les coordonnées de notre héros. */
        mapCollision(&player);

        /* On gère le scrolling */
        centerScrollingOnPlayer();
    }



    /*Gestion de la mort. Si timerMort est différent de 0, c'est qu'il faut réinitialiser le joueur.
    On ignore alors ce qui précède et on joue cette boucle (un wait en fait) jusqu'à ce que
    timerMort == 1. A ce moment-là, on le décrémente encore -> il vaut 0 et on réinitialise
    le jeu avec notre bonne vieille fonction d'initialisation */
    if(player.timerMort > 0)
    {
        player.timerMort--;
        if(player.timerMort == 0)
        {
            changeLevel();
            initializePlayer(0);
        }
    }

}
Exemplo n.º 2
0
void ADSREnvelopeChip::tickInput()
{
    clockInputRegister.refreshInput();
    if (clockInputRegister.getRisingEdge())
        clockInput();
    resetInputRegister.refreshInput();
    
    if (noteOnInput.isConnected())
        noteOnInput.refreshInput();     // if not connected, then no error.. allows us to trigger independtly
    
    if (resetInputRegister.getRisingEdge())
        resetInput();
}
Exemplo n.º 3
0
void UpdateInput(Input_s* input){
	resetInput(input);
	hidScanInput();
	u32 kDown = hidKeysDown();
	if (kDown & KEY_TOUCH) {
		TC = 1;
	}
	if (TC > 0) {
		hidTouchRead(&tp);
		input->touchX = tp.px;
		input->touchY = tp.py;
		TC--;
	}
	checkVButtonTouch(input);
	if(kDown){
		x++;
		//char buffer[100];
		//sprintf(buffer, "Input, %d\n", x);
		//print(buffer);
		if(kDown & KEY_A){
			input->A = true;
		} if(kDown & KEY_B){
			input->B = true;
		} if(kDown & KEY_X){
			input->X = true;
		} if(kDown & KEY_Y){
			input->Y = true;
		}
		
		if(kDown & KEY_UP){
			input->Up = true;
		} if(kDown & KEY_DOWN){
			input->Down = true;
		} if(kDown & KEY_LEFT){
			input->Left = true;
		} if(kDown & KEY_RIGHT){
			input->Right = true;
		}
		
		if(kDown & KEY_START){
			input->Start = true;
		} if(kDown & KEY_SELECT){
			input->Select = true;
		} if(kDown & KEY_L){
			input->L = true;
		} if(kDown & KEY_R){
			input->R = true;
		}
	}
}
Exemplo n.º 4
0
void Tamer::onUpdate(float dt)
{
	Game::Object::onUpdate(dt);

	resetInput();
	standardInputUpdate();

	movementScript(dt);

	static Control::Timer timer( 0.01);
	if (isPressed("s1") && timer.isReady() )
	{
		auto it = new Bullet(this);
		it->setOwner(this);
		 world.push_back( it );
	}
}
Exemplo n.º 5
0
void Character::onUpdate(float dt)
{
	Game::Object::onUpdate(dt);
	gen.update(dt*2, model);
	genSword.update(dt * 2);

	resetInput();
	standardInputUpdate();
	standardMouseUpdate(0.04, Vector2D(7.5f, 7.5f));


	movementScript( 3* dt * (isPressed("s1") ? 2 : 1));
	shieldScript();
	swordScript();

	static Control::Timer timer(2.5);
	if (isPressed("s2") && timer.isReady())
	{
		world.push_back(new BulletGhost(this) );
	}
}
Exemplo n.º 6
0
MainWindow::MainWindow(QApplication &app, ElementDatabase& db)
	: QMainWindow(),
	  Ui::MainWindow(),
	  mApp(&app), 
	  mCompleter(NULL),
	  mLangPath(":/lang"),
	  mInputData(db),
	  mDB(&db),
	  mDataVisualizer(this, db)
{
	mApp->installTranslator(&mTranslator);
#ifdef DEBUG
	if ( ! mLangPath.exists() ) 
		std::cerr << "Unable to determine language directory !" << std::endl;
#endif

	setupUi(this);

	mFormulaDefaultPalette = ntrFormula->palette();
	tblResult->setModel(&mModel);

	// action setup (menu bar)
	menuFile = new QMenu(menubar);
	menuTools = new QMenu(menubar);
	menuLang = new QMenu(menubar);
	menuHelp = new QMenu(menubar);
	addActions();
	connect(actionQuit, SIGNAL(triggered()), &app, SLOT(quit()));
	connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
	connect(actionAbout_Qt, SIGNAL(triggered()), &app, SLOT(aboutQt()));
	connect(actionAbout, SIGNAL(triggered()), this, SLOT(about()));
	connect(actionVisualizeData, SIGNAL(triggered()), &mDataVisualizer, SLOT(show()));
	connect(actionUseSystemLocale, SIGNAL(triggered()), this, SLOT(useSystemLocaleTriggered()));
	selectDefaultLang();
	actionUseSystemLocale->trigger();

	// action setup result table
	connect(actionExpandAll, SIGNAL(triggered()), this, SLOT(expandAll()));
	connect(actionCollapseAll, SIGNAL(triggered()), this, SLOT(collapseAll()));
	connect(actionSelectAll, SIGNAL(triggered()), tblResult, SLOT(selectAll()));
	connect(actionCopySelection, SIGNAL(triggered()), this, SLOT(copyResultTableSelection()));
	connect(tblResult, SIGNAL(expanded(const QModelIndex&)), this, SLOT(expandItem(const QModelIndex&)));
	connect(tblResult, SIGNAL(collapsed(const QModelIndex&)), this, SLOT(expandItem(const QModelIndex&)));

	// populate list of all known GUI input fields
	mFormEntries.append(FormEntry(ntrFormula,   "currentText", lblFormula));
	mFormEntries.append(FormEntry(ntrDensity,   "value", lblDensity));
	mFormEntries.append(FormEntry(ntrXrayEn,    "value", lblXrayEn));
	mFormEntries.append(FormEntry(ntrNeutronWl, "value", lblNeutronWl));
	saveInitialInput();

	// button connectors
	connect(btnClear, SIGNAL(clicked()), this, SLOT(resetInput()));
	connect(btnAddAlias, SIGNAL(clicked()), this, SLOT(addAlias()));
	connect(btnCalc, SIGNAL(clicked()), this, SLOT(doCalc()));

	if (ntrFormula->lineEdit()) {
		mCompleter = new FormulaCompleter(db, ntrFormula->lineEdit(), btnCalc);
		connect(ntrFormula->lineEdit(), SIGNAL(returnPressed()), btnCalc, SLOT(animateClick()));
	}
	connect(ntrDensity, SIGNAL(editingFinished()), btnCalc, SLOT(animateClick()));
	connect(ntrXrayEn, SIGNAL(editingFinished()), btnCalc, SLOT(animateClick()));
	connect(ntrNeutronWl, SIGNAL(editingFinished()), btnCalc, SLOT(animateClick()));

	connect(lblFormattedFormula, SIGNAL(linkActivated(const QString&)), 
		this, SLOT(showElementData(const QString&)));
	connect(&mDataVisualizer, SIGNAL(elementLinkActivated(const QString&)), 
		this, SLOT(showElementData(const QString&)));
}
 void TrackballTransformManipulator::reset()
 {
   resetInput();
 }
Exemplo n.º 8
0
void DacChip::tickInput()
{
    resetInputRegister.refreshInput();
    if (resetInputRegister.getRisingEdge())
        resetInput();
}