示例#1
0
int main(void) {
    initializePlatform();
    initializeLogging();
    initializeTimers();
    initializePower();
    initializeUsb(listener.usb);
    initializeSerial(listener.serial);
    initializeEthernet(listener.ethernet);
    initializeLights();
    initializeBluetooth();

    debug("Initializing as %s", getMessageSet());
    setup();

    for (;;) {
        loop();
        processListenerQueues(&listener);
        updateInterfaceLight();
        updatePower();
    }

    return 0;
}
/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */
	
  uint16_t sensorsVector[NUMBER_OF_SENSORS];
  
  /* variables needed for deciding which direction it should turn more */
  uint16_t robotTurnsRightMotor;
  uint16_t robotTurnsLeftMotor;
  /* in case of a white detection - it may be that simply the robot got completely
   * out of the track - but it should get back to the truck in case it was
   * just loosing a bit the track
   */
    uint16_t flagStopWhite;
  
   /* correction algorith will relay on counting how bad
    * the curve (error), figuring out how many times the 
    * sensor is activated
    */ 
    
    uint16_t correctionS1;
    uint16_t correctionS2;
    
   
  
  uint16_t i; // for serial debug only
  
    flagStopWhite=0;
  
  
  /* initialize the correction counters 
   * they follow how often in a loop cycle the error appears
   */
  correctionS1 = 0;
  correctionS2 = 0;
  
  
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */

  initializePlatform();
  
  /* Wait for a button press before doing anything*/
  while(Button_GetVal()) {}
  
  while (1)
  {

  	  /* Read the input sensors */
  	  readSensors(sensorsVector);

	  robotTurnsLeftMotor = sensorsVector[0] + sensorsVector[1] + sensorsVector[2];
	  robotTurnsRightMotor = sensorsVector[3] + sensorsVector [4] + sensorsVector[5];

	  
	  
#if 1 	  
  	  for (i = 0; i < NUMBER_OF_SENSORS; i++)
  	  {
  		  Term2_SendNum(sensorsVector[i]);
  		  Term2_SendChar(' ');
  	  }
  		  Term2_SendChar('R');
  		  Term2_SendChar('=');		  
  		  Term2_SendNum(robotTurnsRightMotor);
  		  Term2_SendChar(' ');
  		  Term2_SendChar('L');
  		  Term2_SendChar('=');		  
  		  Term2_SendNum(robotTurnsLeftMotor);
  		  Term2_CRLF();  	  
  	  

  	  
  		//setRightMotorSpeed(FULL_SPEED);
  		//setLeftMotorSpeed(FULL_SPEED);
  		  
  		  
  	  /* motor right turns faster case robot turns left as issue is on the left side  */
  	  if (robotTurnsRightMotor > robotTurnsLeftMotor){
  		  
  		/* if last sensor is seeing the black line 
  		 * is pretty bad so speed has to be pretty high
  		 * also if situation repeats correction must be more dramatic
  		 * */
  		  if (sensorsVector[0]==0 && sensorsVector[1]!= 0){ 
  			
  			  if(correctionS1 < TOLERANCE_S1)
  				correctionS1= correctionS1 + CORRECTION_STEP_S1;
  			   			  
  			  setRightMotorSpeed(FULL_SPEED);
  			  setRightMotorSpeed(SPEED_MOTOR_S1_HIGH_REFERENCE + correctionS1);
  			  setLeftMotorSpeed(SPEED_MOTOR_S1_LOW_REFERENCE - correctionS1);
  		      
  			  /* clean up correction flag for RS2*/
  			  WAIT1_Waitus(WAIT_SENSORS_1);
  			  
  			  correctionS2 = 0;
  		  }
  		     
  		  /* the case in which second sensor sees black line
  		   * less critical but also with potential of becoming an 
  		   * issue
  		   */
  		  else if( sensorsVector[1]==0){ 
  			
  			      if(correctionS2 < TOLERANCE_S2)
  				     correctionS2 = correctionS2 + CORRECTION_STEP_S2;
  			   			  
  			      setRightMotorSpeed(SPEED_MOTOR_S2_HIGH_REFERENCE + correctionS2);
  			      setLeftMotorSpeed(SPEED_MOTOR_S2_LOW_REFERENCE - correctionS2);
  			  
  			  
  			      /* clean up the correction flag for RS1 */
  			      correctionS1 = 0;
  			  
  			      WAIT1_Waitus(WAIT_SENSORS_2);
  		  
  		          }
  		  
  		  flagStopWhite=0;
  		    	  
  	  }
  	  
  	  /* motor left turns robot goes to right as issue is on the right side  */ 
  	  if ( robotTurnsLeftMotor > robotTurnsRightMotor){
   
  		/* if last sensor is seeing the black line 
  		 * is pretty bad so speed has to be pretty high
  		 * also if situation repeats correction must be more dramatic
  		*/
  		  if (sensorsVector[5]==0 && sensorsVector[4]!=0){ 
  		  			
  		  	  if(correctionS1 < TOLERANCE_S1)
  		  			correctionS1= correctionS1 + CORRECTION_STEP_S1;
  		  			   			  
  		  	  setRightMotorSpeed(SPEED_MOTOR_S1_LOW_REFERENCE - correctionS1);
  		  	  setLeftMotorSpeed(SPEED_MOTOR_S1_HIGH_REFERENCE + correctionS1);
  		  		  
  		      /* clean up correction flag for S2*/
  		  			  
  		  	  WAIT1_Waitus(WAIT_SENSORS_1); 
  		  	  correctionS2 = 0;
  		  	}
  		  
  		/* the case in which second sensor sees black line
  		  		  		   * less critical but also with potential of becoming an 
  		  		  		   * issue
  		  		  		   */
  		  
  		  else if (sensorsVector[4]==0){ 
  		  			
  		  			  if(correctionS2 < TOLERANCE_S2)
  		  				correctionS2 = correctionS2 + CORRECTION_STEP_S2;
  		  			   			  
  		  			  setRightMotorSpeed(SPEED_MOTOR_S2_LOW_REFERENCE - correctionS2);
  		  			  setLeftMotorSpeed(SPEED_MOTOR_S2_HIGH_REFERENCE + correctionS2);
  		  		    
  		  			  /* clean up the correction flag for RS1 */
  		  			  correctionS1 = 0;
  		  			
  		  			  WAIT1_Waitus(WAIT_SENSORS_2);
  		  	 
  		      }
  		  		  
  		   flagStopWhite=0;
  		  		    		  	  
  	  }
  	    	  
  	  
  	  //case line is correctly read and it should move full speed 
  	  if(robotTurnsRightMotor!=0 && robotTurnsLeftMotor != 0 && sensorsVector[2]==0 && sensorsVector[3]==0){
  		  
  		if(robotTurnsRightMotor==robotTurnsLeftMotor && robotTurnsRightMotor== 2){  
  			setRightMotorSpeed(FULL_SPEED);
  			setLeftMotorSpeed (FULL_SPEED);
  			
  		    WAIT1_Waitus(WAIT_NORMAL);
  		
  		    correctionS1 = 0;
  		    correctionS2 = 0;
  		    flagStopWhite=0;
  		}
	  }
  	  
  	  //case when it is on the black it also stops
  	  if (robotTurnsRightMotor==0 && robotTurnsLeftMotor == 0 ){
  		  
    		setRightMotorSpeed(0);
    		setLeftMotorSpeed (0);
    		
    		correctionS1 = 0;
   	        correctionS2 = 0;
  	        
  	        flagStopWhite=0;
  	  }
  	  
  	  // case when it is on white board not sensor read black it stops
  	  
  	  if (robotTurnsRightMotor==3 && robotTurnsLeftMotor == 3 ){
  		  
  		  if(flagStopWhite==TIME_TO_STOP_ON_WHITE){
  		   		setRightMotorSpeed(0);
    		    setLeftMotorSpeed (0);
  		  }
  		  else{
  			    flagStopWhite++;
  			    WAIT1_Waitus(WAIT_NORMAL);
  		  }

  	  }
#endif
  	    	   	  
  }

   
  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
示例#3
0
/* Starts the connection to the streaming machine */
int LiStartConnection(const char* host, PSTREAM_CONFIGURATION streamConfig, PCONNECTION_LISTENER_CALLBACKS clCallbacks,
	PDECODER_RENDERER_CALLBACKS drCallbacks, PAUDIO_RENDERER_CALLBACKS arCallbacks,
	void* renderContext, int drFlags, int _serverMajorVersion) {
	int err;

    ServerMajorVersion = _serverMajorVersion;
    memcpy(&StreamConfig, streamConfig, sizeof(StreamConfig));

	// Replace missing callbacks with placeholders
	fixupMissingCallbacks(&drCallbacks, &arCallbacks, &clCallbacks);
    memcpy(&VideoCallbacks, drCallbacks, sizeof(VideoCallbacks));
    memcpy(&AudioCallbacks, arCallbacks, sizeof(AudioCallbacks));

	// Hook the termination callback so we can avoid issuing a termination callback
	// after LiStopConnection() is called
	originalTerminationCallback = clCallbacks->connectionTerminated;
	memcpy(&ListenerCallbacks, clCallbacks, sizeof(ListenerCallbacks));
    ListenerCallbacks.connectionTerminated = ClInternalConnectionTerminated;
    
    alreadyTerminated = 0;

	Limelog("Initializing platform...");
	ListenerCallbacks.stageStarting(STAGE_PLATFORM_INIT);
	err = initializePlatform();
	if (err != 0) {
		Limelog("failed: %d\n", err);
		ListenerCallbacks.stageFailed(STAGE_PLATFORM_INIT, err);
		goto Cleanup;
	}
	stage++;
	LC_ASSERT(stage == STAGE_PLATFORM_INIT);
	ListenerCallbacks.stageComplete(STAGE_PLATFORM_INIT);
	Limelog("done\n");
    
    Limelog("Resolving host name...");
    ListenerCallbacks.stageStarting(STAGE_NAME_RESOLUTION);
    err = resolveHostName(host);
    if (err != 0) {
        Limelog("failed: %d\n", err);
        ListenerCallbacks.stageFailed(STAGE_NAME_RESOLUTION, err);
        goto Cleanup;
    }
    stage++;
    LC_ASSERT(stage == STAGE_NAME_RESOLUTION);
    ListenerCallbacks.stageComplete(STAGE_NAME_RESOLUTION);
    Limelog("done\n");

	Limelog("Starting RTSP handshake...");
	ListenerCallbacks.stageStarting(STAGE_RTSP_HANDSHAKE);
	err = performRtspHandshake();
	if (err != 0) {
		Limelog("failed: %d\n", err);
		ListenerCallbacks.stageFailed(STAGE_RTSP_HANDSHAKE, err);
		goto Cleanup;
	}
	stage++;
	LC_ASSERT(stage == STAGE_RTSP_HANDSHAKE);
	ListenerCallbacks.stageComplete(STAGE_RTSP_HANDSHAKE);
	Limelog("done\n");

	Limelog("Initializing control stream...");
	ListenerCallbacks.stageStarting(STAGE_CONTROL_STREAM_INIT);
	err = initializeControlStream();
	if (err != 0) {
		Limelog("failed: %d\n", err);
		ListenerCallbacks.stageFailed(STAGE_CONTROL_STREAM_INIT, err);
		goto Cleanup;
	}
	stage++;
	LC_ASSERT(stage == STAGE_CONTROL_STREAM_INIT);
	ListenerCallbacks.stageComplete(STAGE_CONTROL_STREAM_INIT);
	Limelog("done\n");

	Limelog("Initializing video stream...");
	ListenerCallbacks.stageStarting(STAGE_VIDEO_STREAM_INIT);
	initializeVideoStream();
	stage++;
	LC_ASSERT(stage == STAGE_VIDEO_STREAM_INIT);
	ListenerCallbacks.stageComplete(STAGE_VIDEO_STREAM_INIT);
	Limelog("done\n");

	Limelog("Initializing audio stream...");
	ListenerCallbacks.stageStarting(STAGE_AUDIO_STREAM_INIT);
	initializeAudioStream();
	stage++;
	LC_ASSERT(stage == STAGE_AUDIO_STREAM_INIT);
	ListenerCallbacks.stageComplete(STAGE_AUDIO_STREAM_INIT);
	Limelog("done\n");

	Limelog("Initializing input stream...");
	ListenerCallbacks.stageStarting(STAGE_INPUT_STREAM_INIT);
	initializeInputStream(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey),
		streamConfig->remoteInputAesIv, sizeof(streamConfig->remoteInputAesIv));
	stage++;
	LC_ASSERT(stage == STAGE_INPUT_STREAM_INIT);
	ListenerCallbacks.stageComplete(STAGE_INPUT_STREAM_INIT);
	Limelog("done\n");

	Limelog("Starting control stream...");
	ListenerCallbacks.stageStarting(STAGE_CONTROL_STREAM_START);
	err = startControlStream();
	if (err != 0) {
		Limelog("failed: %d\n", err);
		ListenerCallbacks.stageFailed(STAGE_CONTROL_STREAM_START, err);
		goto Cleanup;
	}
	stage++;
	LC_ASSERT(stage == STAGE_CONTROL_STREAM_START);
	ListenerCallbacks.stageComplete(STAGE_CONTROL_STREAM_START);
	Limelog("done\n");

	Limelog("Starting video stream...");
	ListenerCallbacks.stageStarting(STAGE_VIDEO_STREAM_START);
	err = startVideoStream(renderContext, drFlags);
	if (err != 0) {
		Limelog("Video stream start failed: %d\n", err);
		ListenerCallbacks.stageFailed(STAGE_VIDEO_STREAM_START, err);
		goto Cleanup;
	}
	stage++;
	LC_ASSERT(stage == STAGE_VIDEO_STREAM_START);
	ListenerCallbacks.stageComplete(STAGE_VIDEO_STREAM_START);
	Limelog("done\n");

	Limelog("Starting audio stream...");
	ListenerCallbacks.stageStarting(STAGE_AUDIO_STREAM_START);
	err = startAudioStream();
	if (err != 0) {
		Limelog("Audio stream start failed: %d\n", err);
		ListenerCallbacks.stageFailed(STAGE_AUDIO_STREAM_START, err);
		goto Cleanup;
	}
	stage++;
	LC_ASSERT(stage == STAGE_AUDIO_STREAM_START);
	ListenerCallbacks.stageComplete(STAGE_AUDIO_STREAM_START);
	Limelog("done\n");

	Limelog("Starting input stream...");
	ListenerCallbacks.stageStarting(STAGE_INPUT_STREAM_START);
	err = startInputStream();
	if (err != 0) {
		Limelog("Input stream start failed: %d\n", err);
		ListenerCallbacks.stageFailed(STAGE_INPUT_STREAM_START, err);
		goto Cleanup;
	}
	stage++;
	LC_ASSERT(stage == STAGE_INPUT_STREAM_START);
	ListenerCallbacks.stageComplete(STAGE_INPUT_STREAM_START);
	Limelog("done\n");

	ListenerCallbacks.connectionStarted();

Cleanup:
	return err;
}
示例#4
0
void loadLevel(int levelNumber, SPRITE *platform, ENEMY *enemy, SPRITE *bullet, int *nPlatforms, int *nEnemys, int *nBullets,
               ALLEGRO_DISPLAY **janela){
    int i;
    for(i = 0; i < *nBullets; i++){
        al_destroy_bitmap(bullet[i].image[0]);
    }
    *nBullets = 0;

    if(levelNumber == 1){
        initializePlatform(platform, &nPlatforms, &janela, 0, 0, 1, 1);
        initializeEnemy(enemy, &nEnemys, &janela, 0, 0, 0);

        //Definindo plataformas
        platform[0].positionX = 0*32;
        platform[0].positionY = 0*32;
        platform[0].rotationY = 0;

        platform[1].positionX = 0*32;
        platform[1].positionY = 568;
        platform[1].rotationY = 0;
    }else if(levelNumber == 2){
        initializePlatform(platform, &nPlatforms, &janela, 2, 2, 0, 1);
        initializeEnemy(enemy, &nEnemys, &janela, 2, 0, 0);

        //Definindo plataformas
        platform[0].positionX = 5*32;
        platform[0].positionY = 537;
        platform[0].rotationY = 0;

        platform[1].positionX = 12*32;
        platform[1].positionY = 536;
        platform[1].rotationY = 0;

        platform[2].positionX = 13*32;
        platform[2].positionY = 503;
        platform[2].rotationY = 0;

        platform[3].positionX = 15*32;
        platform[3].positionY = 535;
        platform[3].rotationY = 0;

        platform[4].positionX = 0;
        platform[4].positionY = 568;
        platform[4].rotationY = 0;

        //Definindo inimigos
        enemy[0].sprite.positionX = 8*32;
        enemy[0].sprite.positionY = 536;
        enemy[0].sprite.rotationY = 0;
        enemy[0].sprite.speedX = -2;
        enemy[0].health = 2;
        enemy[0].damage = 1;

        enemy[1].sprite.positionX = 18*32;
        enemy[1].sprite.positionY = 536;
        enemy[1].sprite.rotationY = 0;
        enemy[1].sprite.speedX = -2;
        enemy[1].health = 2;
        enemy[1].damage = 1;
    }else if(levelNumber == 3){
        initializePlatform(platform, &nPlatforms, &janela, 2, 3, 2, 4);
        initializeEnemy(enemy, &nEnemys, &janela, 4, 2, 0);

        //Definindo plataformas
        platform[0].positionX = 23*32;
        platform[0].positionY = 2*32;
        platform[0].rotationY = 0;

        platform[1].positionX = 21*32;
        platform[1].positionY = 4*32;
        platform[1].rotationY = 0;

        platform[2].positionX = 1*32;
        platform[2].positionY = 11*32;
        platform[2].rotationY = 0;

        platform[3].positionX = 1*32;
        platform[3].positionY = 7*32;
        platform[3].rotationY = 0;

        platform[4].positionX = 5*32;
        platform[4].positionY = 9*32;
        platform[4].rotationY = 0;

        platform[5].positionX = 0*32;
        platform[5].positionY = -5*32;
        platform[5].rotationY = 0;

        platform[6].positionX = 24*32;
        platform[6].positionY = -9*32;
        platform[6].rotationY = 0;

        platform[7].positionX = 0*32;
        platform[7].positionY = 568;
        platform[7].rotationY = 0;

        platform[8].positionX = 0*32;
        platform[8].positionY = 13*32;
        platform[8].rotationY = 0;

        platform[9].positionX = -5*32;
        platform[9].positionY = 0;
        platform[9].rotationY = 0;

        platform[10].positionX = 5*32;
        platform[10].positionY = 5*32;
        platform[10].rotationY = 0;

        //Definindo inimigos
        enemy[0].sprite.positionX = 7*32;
        enemy[0].sprite.positionY = 536;
        enemy[0].sprite.rotationY = 0;
        enemy[0].sprite.speedX = -2;
        enemy[0].health = 2;
        enemy[0].damage = 1;

        enemy[1].sprite.positionX = 14*32;
        enemy[1].sprite.positionY = 536;
        enemy[1].sprite.rotationY = 0;
        enemy[1].sprite.speedX = -2;
        enemy[1].health = 2;
        enemy[1].damage = 1;

        enemy[2].sprite.positionX = 14*32;
        enemy[2].sprite.positionY = 14*32;
        enemy[2].sprite.rotationY = 20;
        enemy[2].sprite.speedX = -2;
        enemy[2].health = 2;
        enemy[2].damage = 1;

        enemy[3].sprite.positionX = 1*32;
        enemy[3].sprite.positionY = 8*32;
        enemy[3].sprite.rotationY = 20;
        enemy[3].sprite.speedX = -2;
        enemy[3].health = 2;
        enemy[3].damage = 1;

        enemy[4].sprite.positionX = 14*32;
        enemy[4].sprite.positionY = 12*32;
        enemy[4].sprite.rotationY = 0;
        enemy[4].sprite.speedX = -6;
        enemy[4].health = 4;
        enemy[4].damage = 2;

        enemy[5].sprite.positionX = 14*32;
        enemy[5].sprite.positionY = 4*32;
        enemy[5].sprite.rotationY = 0;
        enemy[5].sprite.speedX = -6;
        enemy[5].health = 4;
        enemy[5].damage = 2;
    }else if(levelNumber == 4){
        initializePlatform(platform, &nPlatforms, &janela, 0, 2, 1, 2);
        initializeEnemy(enemy, &nEnemys, &janela, 3, 1, 0);

        //Definindo plataformas
        platform[0].positionX = 704;
        platform[0].positionY = 16*32;
        platform[0].rotationY = 0;

        platform[1].positionX = 18*32;
        platform[1].positionY = 15*32;
        platform[1].rotationY = 0;

        platform[2].positionX = 768;
        platform[2].positionY = 0;
        platform[2].rotationY = 0;

        platform[3].positionX = 0*32;
        platform[3].positionY = 568;
        platform[3].rotationY = 0;

        platform[4].positionX = -6*32;
        platform[4].positionY = 13*32;
        platform[4].rotationY = 0;

        //Definindo inimigos
        enemy[0].sprite.positionX = 7*32;
        enemy[0].sprite.positionY = 536;
        enemy[0].sprite.rotationY = 0;
        enemy[0].sprite.speedX = -2;
        enemy[0].health = 2;
        enemy[0].damage = 1;

        enemy[1].sprite.positionX = 14*32;
        enemy[1].sprite.positionY = 536;
        enemy[1].sprite.rotationY = 0;
        enemy[1].sprite.speedX = -2;
        enemy[1].health = 2;
        enemy[1].damage = 1;

        enemy[2].sprite.positionX = 14*32;
        enemy[2].sprite.positionY = 14*32;
        enemy[2].sprite.rotationY = 20;
        enemy[2].sprite.speedX = -2;
        enemy[2].health = 2;
        enemy[2].damage = 1;

        enemy[3].sprite.positionX = 14*32;
        enemy[3].sprite.positionY = 12*32;
        enemy[3].sprite.rotationY = 20;
        enemy[3].sprite.speedX = -6;
        enemy[3].health = 4;
        enemy[3].damage = 2;
    }else if(levelNumber == 5){
        initializePlatform(platform, &nPlatforms, &janela, 0, 4, 2, 6);
        initializeEnemy(enemy, &nEnemys, &janela, 0, 2, 1);

        //Definindo plataformas
        platform[0].positionX = 1*32;
        platform[0].positionY = 440;
        platform[0].rotationY = 0;

        platform[1].positionX = 6*32;
        platform[1].positionY = 386;
        platform[1].rotationY = 0;

        platform[2].positionX = 22*32;
        platform[2].positionY = 256;
        platform[2].rotationY = 0;

        platform[3].positionX = 17*32;
        platform[3].positionY = 192;
        platform[3].rotationY = 0;

        platform[4].positionX = 0*32;
        platform[4].positionY = 5*32;
        platform[4].rotationY = 0;

        platform[5].positionX = 24*32;
        platform[5].positionY = 0*32;
        platform[5].rotationY = 0;

        platform[6].positionX = -12*32;
        platform[6].positionY = 159;
        platform[6].rotationY = 0;

        platform[7].positionX = 14*32;
        platform[7].positionY = 321;
        platform[7].rotationY = 0;

        platform[8].positionX = 12*32;
        platform[8].positionY = 353;
        platform[8].rotationY = 0;

        platform[9].positionX = -11*32;
        platform[9].positionY = 504;
        platform[9].rotationY = 0;

        platform[10].positionX = -9*32;
        platform[10].positionY = 536;
        platform[10].rotationY = 0;

        platform[11].positionX = -5*32;
        platform[11].positionY = 568;
        platform[11].rotationY = 0;

        //Definindo inimigos
        enemy[0].sprite.positionX = 4*32;
        enemy[0].sprite.positionY = 472;
        enemy[0].sprite.rotationY = 0;
        enemy[0].sprite.speedX = -6;
        enemy[0].health = 4;
        enemy[0].damage = 2;

        enemy[1].sprite.positionX = 15*32;
        enemy[1].sprite.positionY = 289;
        enemy[1].sprite.rotationY = 0;
        enemy[1].sprite.speedX = -6;
        enemy[1].health = 4;
        enemy[1].damage = 2;

        enemy[2].sprite.positionX = 7*32;
        enemy[2].sprite.positionY = 127;
        enemy[2].sprite.rotationY = 20;
        enemy[2].sprite.speedX = -6;
        enemy[2].health = 6;
        enemy[2].damage = 3;
    }else if(levelNumber == 6){
        initializePlatform(platform, &nPlatforms, &janela, 0, 0, 2, 1);
        initializeEnemy(enemy, &nEnemys, &janela, 0, 0, 2);

        //Definindo plataformas
        platform[0].positionX = 0*32;
        platform[0].positionY = 0*32;
        platform[0].rotationY = 0;

        platform[1].positionX = 24*32;
        platform[1].positionY = 5*32;
        platform[1].rotationY = 0;

        platform[2].positionX = 5*32;
        platform[2].positionY = 568;
        platform[2].rotationY = 0;

        //Definindo inimigos
        enemy[0].sprite.positionX = 10*32;
        enemy[0].sprite.positionY = 536;
        enemy[0].sprite.rotationY = 0;
        enemy[0].sprite.speedX = 6;
        enemy[0].health = 6;
        enemy[0].damage = 3;

        enemy[1].sprite.positionX = 15*32;
        enemy[1].sprite.positionY = 536;
        enemy[1].sprite.rotationY = 0;
        enemy[1].sprite.speedX = -6;
        enemy[1].health = 6;
        enemy[1].damage = 3;
    }else if(levelNumber == 7){
        initializePlatform(platform, &nPlatforms, &janela, 0, 0, 2, 5);
        initializeEnemy(enemy, &nEnemys, &janela, 0, 0, 4);

        //Definindo plataformas
        platform[0].positionX = 0*32;
        platform[0].positionY = -4*32;
        platform[0].rotationY = 0;

        platform[1].positionX = 24*32;
        platform[1].positionY = 0*32;
        platform[1].rotationY = 0;

        platform[2].positionX = 5*32;
        platform[2].positionY = 0*32;
        platform[2].rotationY = 0;

        platform[3].positionX = 0*32;
        platform[3].positionY = 568;
        platform[3].rotationY = 0;

        platform[4].positionX = -5*32;
        platform[4].positionY = 14*32;
        platform[4].rotationY = 0;

        platform[5].positionX = 5*32;
        platform[5].positionY = 9*32;
        platform[5].rotationY = 0;

        platform[6].positionX = -5*32;
        platform[6].positionY = 4*32;
        platform[6].rotationY = 0;

        //Definindo inimigos
        enemy[0].sprite.positionX = 10*32;
        enemy[0].sprite.positionY = 8*32;
        enemy[0].sprite.rotationY = 0;
        enemy[0].sprite.speedX = 6;
        enemy[0].health = 6;
        enemy[0].damage = 3;

        enemy[1].sprite.positionX = 15*32;
        enemy[1].sprite.positionY = 8*32;
        enemy[1].sprite.rotationY = 0;
        enemy[1].sprite.speedX = -6;
        enemy[1].health = 6;
        enemy[1].damage = 3;

        enemy[2].sprite.positionX = 10*32;
        enemy[2].sprite.positionY = 13*32;
        enemy[2].sprite.rotationY = 0;
        enemy[2].sprite.speedX = 6;
        enemy[2].health = 6;
        enemy[2].damage = 3;

        enemy[3].sprite.positionX = 15*32;
        enemy[3].sprite.positionY = 13*32;
        enemy[3].sprite.rotationY = 0;
        enemy[3].sprite.speedX = -6;
        enemy[3].health = 6;
        enemy[3].damage = 3;
    }else if(levelNumber == 8){
        initializePlatform(platform, &nPlatforms, &janela, 0, 13, 1, 0);
        initializeEnemy(enemy, &nEnemys, &janela, 0, 0, 0);

        //Definindo plataformas
        platform[0].positionX = 23*32;
        platform[0].positionY = 568;
        platform[0].rotationY = 0;

        platform[1].positionX = 21*32;
        platform[1].positionY = 536;
        platform[1].rotationY = 0;

        platform[2].positionX = 19*32;
        platform[2].positionY = 504;
        platform[2].rotationY = 0;

        platform[3].positionX = 17*32;
        platform[3].positionY = 472;
        platform[3].rotationY = 0;

        platform[4].positionX = 15*32;
        platform[4].positionY = 440;
        platform[4].rotationY = 0;

        platform[5].positionX = 13*32;
        platform[5].positionY = 408;
        platform[5].rotationY = 0;

        platform[6].positionX = 11*32;
        platform[6].positionY = 376;
        platform[6].rotationY = 0;

        platform[7].positionX = 9*32;
        platform[7].positionY = 344;
        platform[7].rotationY = 0;

        platform[8].positionX = 7*32;
        platform[8].positionY = 312;
        platform[8].rotationY = 0;

        platform[9].positionX = 5*32;
        platform[9].positionY = 280;
        platform[9].rotationY = 0;

        platform[10].positionX = 3*32;
        platform[10].positionY = 248;
        platform[10].rotationY = 0;

        platform[11].positionX = 1*32;
        platform[11].positionY = 216;
        platform[11].rotationY = 0;

        platform[12].positionX = -1*32;
        platform[12].positionY = 215;
        platform[12].rotationY = 0;

        platform[13].positionX = 24*32;
        platform[13].positionY = -4*32;
        platform[13].rotationY = 0;
    }
}