Exemple #1
0
void idle() {
    int dt;
    nebu_System_Sleep(10);
    dt = nebu_Time_GetElapsedSinceLastFrame();
    if(dt < 10)
        return;
    nebu_Time_SetCurrentFrameTime( nebu_Time_GetElapsed() );
    checkKeyboard(dt);
}
Exemple #2
0
void recordRhythms(void) {
   // remove all previous notes from input
   while (synth.getNoteCount() > 0) synth.extractNote();

   cout << "Play four notes to record rhythms and durations for chords" << endl;
   int oncount = 0;
   int offcount = 0;
   int finished[4] = {0};
   int offnote;
   int offtime;
   int playedNotes[4] = {0};
   int startTime = 0;
   MidiEvent noteMessage;
   while (oncount <= 4 && offcount <=4 ) {
      if (interfaceKeyboard.hit())  checkKeyboard();
      synth.processIncomingMessages();
      if (synth.getNoteCount() > 0) {
         noteMessage = synth.extractNote();
         if (oncount < 4 && noteMessage.getP2() != 0) {
            if (oncount == 0)  startTime = noteMessage.tick;
            playedNotes[oncount] = noteMessage.getP1();
            attack[oncount] = noteMessage.getP2();
            onset[oncount] = noteMessage.tick - startTime;
            oncount++;
         } else if (noteMessage.getP2() == 0) {
            offtime = noteMessage.tick;
            offnote = noteMessage.getP1();
            for (int i=0; i<oncount; i++) {
               if ((offnote == playedNotes[i]) && (finished[i] == 0)) {
                  duration[i] = offtime - onset[i] - startTime;
                  offcount++;
                  finished[i] = 1;
                  break;
               }
            }
         }
      }
      if ((oncount >= 4) && (offcount >=4))  break;
   }

   cout << "Finished recording new rhythms and durations" << endl;

   cout << "Onsets:    \t" << onset[0] << "\t" << onset[1]
        << "\t" << onset[2] << "\t" << onset[3] << endl;
   cout << "durations: \t" << duration[0] << "\t" << duration[1]
        << "\t" << duration[2] << "\t" << duration[3] << endl;

}
Exemple #3
0
/*JUEGO*/
void game(){
  u8 atkObj = 0;

  initVariables(1);
  initPlayer(map);
  initNivel();
  initEnemies(map);

   cpct_clearScreen(0);
   drawMap(map);
   while (1){
    if(finish == 1) return;
    //Esperar el retrazado
    cpct_waitVSYNC();

    //Desdibujar personajes
    erases();

    //Dibujar pickups
    if(temp == 10)
        drawPickUps(n.corazon,n.bullet);

    //Dibujar personajes
    draws();

    //Dibujar fatiga
    if(temp == 10){
        if(player.atk < 20) drawFatiga(player.atk,2);
        else if(player.atk > 20) drawFatiga(player.atk,1);
        else drawFatiga(player.atk,0);
    }
    //guardar datos anteriores
    if(temp%2 == 0){
        player.lx = player.x;
        player.ly = player.y;
    }

    if(enemy.life > 0){
        if(temp%2 == 1){
            enemy.lx = enemy.x;
            enemy.ly = enemy.y;
        }

       move();
        switch(checkCollisions(player.x, player.y, enemy.x, enemy.y, player.atk)){
          case 1:
            erase(enemy.lx,enemy.ly,0);
            enemy.x = enemy.ox;
            enemy.y = enemy.oy;
            enemy.lx = enemy.x;
            enemy.ly = enemy.y;
            enemy.ox = originse[map-1][4];
            enemy.oy = originse[map-1][5];
            enemy.life -= 1;
            player.atk = 20;
            enemy.pursue = 0;
            break;
          case 2:
            erase(player.lx,player.ly,0);
            player.x =originsp[map-1][0];
            player.y = originsp[map-1][1];
            player.lx =originsp[map-1][0];
            player.ly = originsp[map-1][1];
            player.life -= 1;
            player.atk = 20;
            enemy.pursue = 0;
            break;
        }
    }
    if(temp > 10)
        temp = 0;
    temp += 1;
    player.latk = player.atk;
      //Comprobar teclado
      cpct_scanKeyboard_f();
      player.sprite = checkKeyboard();
      checkBoundsCollisions(&n.corazon,&n.bullet);

      if(arrow == 1){
        moveObject();
        bound = checkArrowCollisions();
        if(object.dir == 2 || object.dir == 8)
            atkObj = 21;
        else
            atkObj = 22;
       if(enemy.life > 0 && checkCollisions(object.x, object.y, enemy.x, enemy.y, atkObj) == 1 && bound == 0){
         enemy.life -= 1;
         erase(enemy.lx,enemy.ly,0);
         enemy.x = enemy.ox;
         enemy.y = enemy.oy;
         enemy.lx = enemy.x;
         enemy.ly = enemy.y;
         enemy.pursue = 0;
         object.vivo = 0;
         bound = 1;
       }
      }
      
      if(player.life == 0){
        gameOver();
        finish = 1;
      } 
      

   }
}
Exemple #4
0
void Scene::doFrame() {
	Player &player = _vm->_game->_player;
	bool flag = false;

	if (_action._selectedAction || !player._stepEnabled) {
		_action.clear();
		_action._selectedAction = 0;
	}

	if (!_vm->_game->_trigger && !player._trigger) {
		// Refresh the dynamic hotspots if they've changed
		if (_dynamicHotspots._changed)
			_dynamicHotspots.refresh();

		// Check all on-screen visual objects
		_vm->_game->_screenObjects.check(player._stepEnabled && !player._needToWalk &&
				!_vm->_game->_fx);
	}

	if (_action._selectedAction && player._stepEnabled && !player._needToWalk &&
			!_vm->_game->_trigger && !player._trigger) {
		_action.startAction();
		if (_action._activeAction._verbId == Nebular::VERB_LOOK_AT) {
			_action._activeAction._verbId = VERB_LOOK;
			_action._savedFields._command = false;
		}

		flag = true;
	}

	if (flag || (_vm->_game->_trigger && _vm->_game->_triggerMode == SEQUENCE_TRIGGER_PREPARE)) {
		doPreactions();
	}

	player.newWalk();
	if (!_vm->_game->_fx)
		_frameStartTime = _vm->_events->getFrameCounter();

	// Handle parser actions as well as game triggers
	if ((_action._inProgress && !player._moving && !player._needToWalk &&
			(player._facing == player._turnToFacing) && !_vm->_game->_trigger) ||
			(_vm->_game->_trigger && (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PARSER))) {
		doAction();
	}

	if (_currentSceneId != _nextSceneId) {
		_freeAnimationFlag = true;
	} else {
		doSceneStep();
		checkKeyboard();

		if (_currentSceneId != _nextSceneId) {
			_freeAnimationFlag = true;
		} else {
			player.nextFrame();

			// Cursor update code
			updateCursor();

			if (!_vm->_game->_trigger) {
				// Handle any active sequences
				_sequences.tick();

				// Handle any active animation
				if (_activeAnimation)
					_activeAnimation->update();
			}

			// If the debugget flag is set, show the mouse position
			int mouseTextIndex = 0;
			if (_vm->_debugger->_showMousePos) {
				Common::Point pt = _vm->_events->mousePos();
				Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y);
				mouseTextIndex = _kernelMessages.add(Common::Point(5, 5),
					0x203, 0, 0, 1, msg);
			}

			if (!_vm->_game->_trigger) {
				if (_reloadSceneFlag || _currentSceneId != _nextSceneId)
					_kernelMessages.reset();
				_kernelMessages.update();
			}

			_userInterface._uiSlots.draw(!_vm->_game->_fx, _vm->_game->_fx);

			// Write any text needed by the interface
			if (_vm->_game->_fx)
				_userInterface.drawTextElements();

			// Draw any elements
			drawElements((ScreenTransition)_vm->_game->_fx, _vm->_game->_fx);

			// Handle message updates
			if (_vm->_game->_fx) {
				uint32 priorTime = _vm->_game->_priorFrameTimer;
				uint32 newTime = _vm->_events->getFrameCounter();
				_sequences.delay(priorTime, newTime);
				_kernelMessages.delay(priorTime, newTime);
			}

			if (_vm->_debugger->_showMousePos)
				// Mouse position display isn't persistent, so remove it
				_kernelMessages.remove(mouseTextIndex);

			// Original had a debugger check/call here to allow pausing after
			// drawing each frame. Not implemented under ScummVM
		}
	}

	if (_vm->_game->_fx)
		_cyclingActive = true;
	_vm->_game->_fx = kTransitionNone;

	// Handle freeing animation if necessary
	if (_activeAnimation && _activeAnimation->freeFlag())
		_freeAnimationFlag = true;
	if (_freeAnimationFlag)
		freeAnimation();
}