Ejemplo n.º 1
0
//Collision Check
void EnemyCol(void){int j;
	for(j=0;j<15;j++){
	if(Missile.life){
		if ((Missile.x - Enemy[j].x) < 35){
			if ((Missile.y - Enemy[j].y) < 30){
				if(Enemy[j].life>0){
					Missile.life = 0;
					LCD_DrawBMP(missile1, Missile.x, Missile.y);;
					Enemy[j].life--;
					if(Enemy[j].life==0){
						LCD_DrawFilledRect(Enemy[j].x,Enemy[j].y,32,20,BLACK);
					}	
				}	
			}	
		}
	}
	}
		for(j=0;j<4;j++){
	if(Missile.life){
		if ((Missile.x - Bunker[j].x) < 32){
			if ((Missile.y - Bunker[j].y) < 5){
				if(Bunker[j].life>0){
					Missile.life = 0;
					LCD_DrawBMP(missile1, Missile.x, Missile.y);;
					Bunker[j].life--;
					if(Bunker[j].life==0){
						LCD_DrawFilledRect(Bunker[j].x,Bunker[j].y,32,5,BLACK);
					}	
				}	
			}	
		}
	}
	}
}
Ejemplo n.º 2
0
void drawArrow(void){int x, y;
	// cover old arrow
	LCD_DrawFilledRect(prevX,prevY,20,20,BLACK);

	// draw new arrow
	if (ADCMail < 1024){
		x = 92;
		y = 201;
		y -= (185 * (ADCMail/1024.0));
		LCD_DrawBMP(RightArrow, x, y);
	}
	else if (ADCMail < 2048){
		x = 103;
		x += (185 * ((ADCMail-1024)/1024.0));
		y = 5;
		LCD_DrawBMP(DownArrow, x, y);
	}
	else if (ADCMail < 3072){
		x = 300;
		y = 16;
		y += (185 * ((ADCMail-2048)/1024.0));
		LCD_DrawBMP(LeftArrow, x, y);
	}
	else{
		x = 289;
		x -= (185 * ((ADCMail-3072)/1024.0));
		y = 213;
		LCD_DrawBMP(UpArrow, x, y);
	}	
	prevX = x;
	prevY = y;	
}
Ejemplo n.º 3
0
//Draw Screen Status
void DrawBuffer1(void){int j;
	for(j=0; j<15; j++){
		if(Enemy[j].life != 0){
			LCD_DrawBMP(Enemy[j].image, Enemy[j].x, Enemy[j].y);
		}
	}	
	for(j=0; j<4; j++){
		LCD_DrawBMP(Bunker[j].image, Bunker[j].x, Bunker[j].y);
	}
	if(Missile.life){		
		LCD_DrawBMP(Missile.image, Missile.x, Missile.y);
	}	
	LCD_DrawBMP(Player.image, Player.x, Player.y);
}
/*******************************************************************************
* Function Name  : Mass_Storage_Start
* Description    : Starts the mass storage demo.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Mass_Storage_Start (void)
{
  /* Disble the JoyStick interrupts */
  IntExtOnOffConfig(DISABLE);

  /* Clear the LCD screen */
  LCD_Clear(White);

  LCD_SetDisplayWindow(160, 223, 128, 128);
 
  LCD_DrawBMP(0x00647C00);

  /* Disable LCD Window mode */
  LCD_WindowModeDisable();
  
  /* Set the Back Color */
  LCD_SetBackColor(Blue);
  /* Set the Text Color */
  LCD_SetTextColor(White); 

  if(MSD_Init() != 0x00)
  {
    LCD_DisplayStringLine(Line8, " No MSD Card Present");
    LCD_DisplayStringLine(Line9, "  To exit Press SEL ");

    /* Loop until SEL key pressed */
    while(ReadKey() != SEL)
    {
    }
  }
  else
  {
    Get_Medium_Characteristics();

    /* Display the "  Plug the USB   " message */
    LCD_DisplayStringLine(Line8, " Plug the USB Cable ");
    LCD_DisplayStringLine(Line9, "Exit:  Push JoyStick");
    
    /* Intialize the USB cell */
    USB_Init();
  
    LCD_ClearLine(Line9);
    /* Display the "To stop Press SEL" message */
    LCD_DisplayStringLine(Line8, "  To stop Press SEL ");

    /* Loop until SEL key pressed */
    while(ReadKey() != SEL)
    {
    }

    PowerOff();
  }
  LCD_Clear(White);
  DisplayMenu();
  IntExtOnOffConfig(ENABLE);
  /* Flush SPI1 Data Register */
  SPI_I2S_ReceiveData(SPI1);
}
Ejemplo n.º 5
0
void Board_Init(void){int tileLen, row, col, tileX, tileY;
	
	// Background Color
	LCD_DrawFilledRect(0,0,320,240,BLACK);
	
	// Sidebar Color
	LCD_DrawFilledRect(0,0,91,240,RED);
	LCD_DrawRect(0,0,91,239,BURNTORANGE);	
	
	// Board Frame
	LCD_DrawFilledRect(boardX, boardY, boardLen, boardLen, ORANGE);
	
	// Title
	LCD_DrawBMP(Title, 13, 7);
	
	// Scoreboard/Credits
	LCD_DrawFilledRect(6,59,79,175,BLACK);
	LCD_DrawRect(6,59,79,174,YELLOW);	
	LCD_SetTextColor(255,245,200);	
	LCD_Goto(2,9);	
	printf("Score:");
	LCD_Goto(2,15);
	printf("Highscore:");
	LCD_Goto(2,12);
	printf("Time:");

	// Credits
	LCD_Goto(4,7);
	LCD_SetTextColor(255,255,240);
	printf("LAB 10");	
	LCD_Goto(2,23);
	printf("Created by:");
	LCD_Goto(2,24);
	printf("Ryan Norton");
	LCD_Goto(2,25);
	printf("Andrew Grado");
	
	// Initialize Tile Position Array and Empty Board
	tileLen = (boardLen - (5 * tilePadding)) / 4;
	for (row=0; row<4; row++){
		for (col=0; col<4; col++){
			
			// Calculate tile coordinates
			tileX = row * (tileLen + tilePadding) + tilePadding + boardX;
			tileY = col * (tileLen + tilePadding) + tilePadding + boardY;
			
			// Initialize board with empty tiles
//			LCD_DrawFilledRect(tileX, tileY, tileLen, tileLen, GREEN);
			
			// Initialize tile position array
			tileCoords[col * 4 + row + 1][0] = tileX;
			tileCoords[col * 4 + row + 1][1] = tileY - 1;
		}
	}
	
}
/*------------------------------------------------------------------------------------*/
void DrawIcon(IconName _IconName, IconStatus _Status) {
    LCD_SetColors(LCD_COLOR_BLACK, LCD_COLOR_WHITE);
    switch (_IconName) {
    case Icon_TopBar_Clock:
        LCD_DrawChar(3, (20-Image_TopBar_Clock.height)/2, (ptImage)&Image_TopBar_Clock);
        break;
    case Icon_TopBar_Battery:
        LCD_DrawBMP(297, (20-Image_TopBar_Battery.height)/2, (ptImage)&Image_TopBar_Battery, 0);
        break;
    case Icon_TopBar_FlyTime:
        LCD_DrawBMP(142, (20-Image_TopBar_FlyTime.height)/2, (ptImage)&Image_TopBar_FlyTime, 0);
        break;
    case Icon_TopBar_Temper:
        LCD_DrawBMP(214, (20-Image_TopBar_Temper.height)/2, (ptImage)&Image_TopBar_Temper, 0);
        break;
    case Icon_TopBar_DesatTime:
        LCD_DrawBMP(74, (20-Image_TopBar_DesatTime.height)/2, (ptImage)&Image_TopBar_DesatTime, 0);
        break;
    case Icon_BottomBar_ArrowUp:
        LCD_DrawBMP(112, ((20-Image_BottomBar_ArrowUp.height)/2)+220, (ptImage)&Image_BottomBar_ArrowUp, 0);
        break;
    case Icon_BottomBar_ArrowDown:
        LCD_DrawBMP(185, ((20-Image_BottomBar_ArrowUp.height)/2)+220, (ptImage)&Image_BottomBar_ArrowUp, 2);
        break;
    case Icon_BottomBar_ArrowLeft:
        LCD_DrawBMP(40, ((20- Image_BottomBar_ArrowLeft.height)/2)+220, (ptImage)&Image_BottomBar_ArrowLeft, 0);
        break;
    case Icon_BottomBar_Select:
        LCD_DrawBMP(258, ((20-Image_BottomBar_Select.height)/2)+220, (ptImage)&Image_BottomBar_Select, 0);
        break;
    case Icon_HomeMenu_GoDive:
        switch(_Status) {
        case Select:
            LCD_SetColors(Black, White);
            LCD_FillRect(26, 30, 57, 57, Blue);
            break;
        default:
            LCD_SetColors(White, Black);
            LCD_FillRect(26, 30, 57, 57, Black);
            break;
        }
        LCD_DrawChar((26+((57-Image_HomeMenu_GoDive.width)/2)), 34,(ptImage)&Image_HomeMenu_GoDive);
        break;
    default:
        LCD_FillRect(0, 120, 120, 3, LCD_COLOR_RED);//Error notification
        break;
    }
}
Ejemplo n.º 7
0
// Update sprite images
void Update(void){int j;
	EnemyCol();	
	 for(j=0;j<5;j++){
		if(Enemy[j].life == 0){
			switch(Enemy[j].life){
				case 0:
					Enemy[j].image = missile1;
				case 1:
					Enemy[j].image = ATMB;
			}
		}
	}
	for(j=5;j<10;j++){
			switch(Enemy[j].life){
				case 0:
					Enemy[j].image = missile1;
				case 1:
					Enemy[j].image = OUB;			
			}
	}		
	for(j=10;j<15;j++){
			switch(Enemy[j].life){
				case 0:
					Enemy[j].image = missile1;
				case 1:
					Enemy[j].image = TTechB;
			}
	}		
	for(j=0; j<4; j++){
			switch(Bunker[j].life){
				case 0:
					Bunker[j].image = missile1;
				case 1:
					Bunker[j].image = Bunker2;
				case 2:
					Bunker[j].image = Bunker1;
		}
	}
	if(Missile.y <= 20 || Missile.life==0){
		Missile.life = 0;
		LCD_DrawBMP(missile1, Missile.x, Missile.y);
	}
}
Ejemplo n.º 8
0
//GAME
int main(void){unsigned long i=64,j=0;
  PLL_Init();  // Set the clocking to run at 80MHz from the PLL.
  LCD_Init();  // Initialize LCD
	Piano_Init();
	Sound_Init();
	ADC_Init();		//initialize ADC
	ADC_SetChannel(1); //PE2
	
	Missile_Init();
	Enemy1_Init();
	
  LCD_Goto(10,0);
  LCD_SetTextColor(255,0,0); // yellow= red+green, no blue
  printf("Welcome to Pokemon Capture!");
	delay_long();
	LCD_DrawFilledRect(0,0,320,80,0x00);
	delay_short();
	
	while((GPIO_PORTE_DATA_R&0x01)==0){
		LCD_Goto(10,0);
		printf("Press any button to begin...");
		delay_blink();
		LCD_DrawFilledRect(0,0,320,80,0x00);
		delay_blink();
	}
	delay_short();
	
	LCD_SetTextColor(255,255,0);
	LCD_Goto(0,0);
	printf("Tragedy has struck Pallet Town! Four Pokemon have    escaped from their Pokeballs, and it's your job to   put them back where they belong.");
	delay_long();
	delay_long();
	delay_long();
	LCD_DrawFilledRect(0,0,320,80,0x00);
	delay_short();
	
	LCD_Goto(0,0);
	printf("Use the slider to aim, and when you think you have a shot, press the button to throw your Pokeball.");
	delay_long();
	delay_long();
	delay_long();
	LCD_DrawFilledRect(0,0,320,80,0x00);
	delay_blink();
	
	LCD_Goto(0,0);
	printf("You only have so many Pokeballs, so be smart where   you throw them!");
	delay_long();
	delay_long();
	LCD_DrawFilledRect(0,0,320,80,0x00);
	delay_short();
	
	LCD_Goto(0,0);
	printf("Good luck!");
	delay_long();
	LCD_DrawFilledRect(0,0,320,80,0x00);
	delay_short();
	
	LCD_SetTextColor(255,0,0);
	LCD_Goto(0,0);
	printf("Captured:");
	
	LCD_SetTextColor(0,255,0);
	LCD_Goto(14,0);
	printf("Pokeballs Left:");
	
	LCD_SetTextColor(0,0,255);
	LCD_Goto(35,0);
	printf("Accuracy:");
  LCD_DrawLine(10,16,310,16,BURNTORANGE);
  
  Timer2_Init(7256); // 11kHz
	SysTick_Init(2666667);	//30 Hz
  EnableInterrupts();
	
	Pokeballs = 25;
  while(1){
		if((25-(hits+misses))==0){
			if(kill!=4){
				DisableInterrupts();
				LCD_SetTextColor(255,0,0);
				
				LCD_DrawFilledRect(0,0,320,80,0x00);
				delay_short();
				
				LCD_Goto(0,0);
				printf("Sorry, you were not able to catch all the Pokemon.");
				delay_long();
				delay_long();
				LCD_DrawFilledRect(0,0,320,80,0x00);
				delay_short();
				
				LCD_Goto(0,0);
				printf("Try again.");
				delay_long();
				LCD_DrawFilledRect(0,0,320,80,0x00);
				delay_short();
				
				while(1){
				LCD_Goto(0,0);
				printf("Press RESET to play again.");
				delay_blink();
				LCD_DrawFilledRect(0,0,320,80,0x00);
				delay_blink();
				}
			}
		}
				
		if(kill==4){
			DisableInterrupts();
			LCD_SetTextColor(0,255,255);
			
			LCD_DrawFilledRect(0,0,320,80,0x00);
			delay_short();
			
			LCD_Goto(0,0);
			printf("Congratulations! You have captured all the Pokemon!");
			delay_long();
			delay_long();
			LCD_DrawFilledRect(0,0,320,80,0x00);
			delay_short();
			
			LCD_Goto(0,0);
			printf("You are now a Pokemon Master!");
			delay_long();
			delay_long();
			LCD_DrawFilledRect(0,0,320,80,0x00);
			delay_short();
			
			while(1){
				LCD_Goto(0,0);
				printf("Press RESET to play again.");
				delay_blink();
				LCD_DrawFilledRect(0,0,320,80,0x00);
				delay_blink();
			}
		}
		
		
    if(Semaphore){
			
			LCD_SetTextColor(255,0,0);
			LCD_Goto(10,0);
			LCD_PrintInteger(kill);
			
			LCD_SetTextColor(0,255,0);
			LCD_Goto(30,0);
			LCD_PrintInteger(25-(hits+misses));
			if((25-(hits+misses))<10){
				LCD_Goto(31,0);
				printf(" ");
			}
			
			LCD_SetTextColor(0,0,255);
			LCD_Goto(45,0);
			LCD_PrintInteger(hits/(hits+misses));
			
			//draw ship
			if(Ship_Position>288){
				Ship_Position=288;
			}
      LCD_DrawBMP(PlayerShip,Ship_Position,220);
			LCD_DrawFilledRect(0,220,Ship_Position,9,0x00);
			LCD_DrawFilledRect(Ship_Position+32,220,320-(Ship_Position+32),9,0x00);
			
			
      for(j=0;j<1;j++){
				if(Missile[j].life==1){
					LCD_DrawBMP(Missile[j].image, Missile[j].x, Missile[j].y);
				} else{
					LCD_DrawFilledRect(Missile[j].x,Missile[j].y,16,18,0x00);
				}
				if(Missile[j].y<=18){
					LCD_DrawFilledRect(Missile[j].x,Missile[j].y,16,18,0x00);
					Missile[j].life=0;
					misses++;
				}
			}
			
      for(i=0;i<4;i++){
				if(Enemy1[i].life!=0){
					LCD_DrawBMP(Enemy1[i].image,Enemy1[i].x,Enemy1[i].y);
				}
				else{
					LCD_DrawFilledRect(Enemy1[i].x,Enemy1[i].y,32,32,0x00);
				}
			}
			
			LCD_DrawFilledRect(0,17,320,4,0x00);
			
      Semaphore = 0;
    }
  }
}
Ejemplo n.º 9
0
void drawTile(int value, int tileNum) {
	if (value == 2){
		LCD_DrawBMP(Number2, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 4){
		LCD_DrawBMP(Number4, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 8){
		LCD_DrawBMP(Number8, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 16){
		LCD_DrawBMP(Number16, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 32){
		LCD_DrawBMP(Number32, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 64){
		LCD_DrawBMP(Number64, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 128){
		LCD_DrawBMP(Number128, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 256){
		LCD_DrawBMP(Number256, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 512){
		LCD_DrawBMP(Number512, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 1024){
		LCD_DrawBMP(Number1024, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
	else if (value == 2048){
		LCD_DrawBMP(Number2048, tileCoords[tileNum][0], tileCoords[tileNum][1]);
	}
}
Ejemplo n.º 10
0
void displayHighestTile(void){int high, i, value;
	high = 2;
	for (i=1; i<17; i++){
		value = getValue(i);
		if (value > high){
			high = value;
		}
	}
	if (high == 2){
		LCD_DrawBMP(Number2, 26, 158);
	}
	else if (high == 4){
		LCD_DrawBMP(Number4, 26, 158);
	}
	else if (high == 8){
		LCD_DrawBMP(Number8, 26, 158);
	}
	else if (high == 16){
		LCD_DrawBMP(Number16, 26, 158);
	}
	else if (high == 32){
		LCD_DrawBMP(Number32, 26, 158);
	}
	else if (high == 64){
		LCD_DrawBMP(Number64, 26, 158);
	}
	else if (high == 128){
		LCD_DrawBMP(Number128, 26, 158);
	}
	else if (high == 256){
		LCD_DrawBMP(Number256, 26, 158);
	}
	else if (high == 512){
		LCD_DrawBMP(Number512, 26, 158);
	}
	else if (high == 1024){
		LCD_DrawBMP(Number1024, 26, 158);
	}
	else if (high == 2048){
		LCD_DrawBMP(Number2048, 26, 158);
	}	
}
Ejemplo n.º 11
0
//////////////////////////////////////////////////////////////////////////***START OF PROGRAM***//////////////////////////////////////////////////////////////////////////////////////////////
int main(void){
	
//Initialization
	PLL_Init();  // Set the clocking to run at 80MHz from the PLL.
  LCD_Init();  // Initialize LCD
  LCD_Goto(10,0);
  LCD_SetTextColor(255,255,0); // yellow= red+green, no blue
  printf("Lab 10");
  LCD_DrawLine(10,16,310,16,BURNTORANGE);
	ADC_Initialize();
	Timer2_Init(7256);
	Timer2A_Stop();
	SysTick_Init();





	
///////////////////////////////////////////////////////////////////////////Set Up Waves///////////////////////////////////////////////////////////////////////////////////////////////
	while(1){
     	//set up for the wave 1 (11 means wave needs to be setup, 10 means wave is set up)
			if (wave==11) {  
				wavesize=5;
				enemycount=0;
				LCD_SetCursor(140,120);
				LCD_SetTextColor(255,0,0);
        LCD_PrintString("WAVE ONE");	
				LCD_SetTextColor(0,0,0);
				LCD_PrintString("WAVE ONE");
				 
				enemy[0].x=50;
				enemy[1].x=90;
				enemy[2].x=130;
				enemy[3].x=170;
				enemy[4].x=210;
				for (k=0;k<5;k++) {
					enemy[k].y=40;
					enemy[k].s=1;
					enemy[k].e=0;
					enemy[k].c=0;
					enemy[k].b=0;
					wave=10;
				}
			}
     //set up for wave 2 (22 means wave needs to be setup, 20 means wave is set up)
    	//e: so we don't print eraser more than once
			//s: so we know the state of the sprite
			//c; so we don't count the death of a sprite more than once
			
	if (wave==21) {  
        wavesize=15;				
				enemycount=0;
				LCD_SetCursor(140,120);
				LCD_SetTextColor(255,0,0);
        LCD_PrintString("WAVE TWO");	
				LCD_SetTextColor(0,0,0);
				LCD_PrintString("WAVE TWO"); 
				enemy[0].x=50;
				enemy[1].x=90;
				enemy[2].x=130;
				enemy[3].x=170;
				enemy[4].x=210;
				for (k=0;k<5;k++) {
					enemy[k].y=40;
					enemy[k].s=1;
					enemy[k].e=0;
					enemy[k].c=0;
					enemy[k].b=0;
	       
				}
				for (k=5;k<10;k++) {
					enemy[k].s=4;       //set newer coming enemies to 4, so they don't get counted as dead when they don't arrive yet (count happens after printing)
					enemy[k].e=0;
					enemy[k].y=40;
					enemy[k].x=50;
					enemy[k].c=0;
					enemy[k].b=0;
				}
				for (k=10;k<15;k++) {
					enemy[k].s=4;
					enemy[k].s=4;       //set newer coming enemies to 4, so they don't get counted as dead when they don't arrive yet (count happens after printing)
					enemy[k].e=0;
					enemy[k].y=64;
					enemy[k].x=296;
					enemy[k].c=0;
					enemy[k].b=0;
				}
				wave=20;
			}
		//set up for wave 3
		//set up for wave 3
			if(wave==31) {
				wavesize=1;
			  enemycount=0;
				LCD_SetCursor(140,30);
				LCD_SetTextColor(255,0,0);
        LCD_PrintString("Time For Ziping");	
				for(k=0;k<10;k++) {enemy[k].x=0;enemy[k].y=0;enemy[k].s=0;;enemy[k].e=0;}
				enemy[0].s=1;
				enemy[0].x=100;
				enemy[0].y=40;
				enemy[0].b=0;
				enemy[0].e=0;
				wave=30;
			}
						
						
						
 ////////////////////////////////////////////////////////////////////////////Update and Print User Ship/////////////////////////////////////////////////////////////////////////////////////////          
		if(Semaphore){																//wait for SysTick
			Semaphore = 0; 																	//"acknowledge" SysTick
			ADCData = ADC_In();
			Position=(ADCData*.4053751277)+157.0113976;			//position 0-2000
			xShip = ((Position)*.14)+20;									//x pixel coordinate of center of ship (.14 = 280/2000)
			LCD_DrawBMP(UshipErase,xShipTrail,200);					//erase previous image
			LCD_DrawBMP(userShip,xShip,200);
			xShipTrail = xShip;
			
			
			
			
			
////////////////////////////////////////////////////////////////////////////////////Update Enemies/////////////////////////////////////////////////////////////////////////////////////////////

			//enemy ship update coordinates for wave 1	 (s=1 means alive, s=0 means just dead, s=2 means the moment of death)
		  if (wave==10) {
			for (k=0;k<5;k++){
						if (enemy[k].s == 1) {
							enemy[k].y = enemy[k].y +1;
											trainWreckL = xShip-enemy[k].x;												//enemy within left boundary of ship
											trainWreckR = enemy[k].x - xShip;											//enemy within right boundary of ship
											
											if( (enemy[k].y >= 176) &&
													(((trainWreckL <24)&&(trainWreckL >0) )||((trainWreckR < 30)&&(trainWreckR > 0))) ){
														enemy[k].s = 2;
														DEATH();								
														userDeath++;
													}	
					  if (enemy[k].y>=210) {enemy[k].s=0;}
						} }
					}
			//enemy ship update coordinates for wave 2 
						//enemy ship update coordinates for wave 2 
			else if (wave==20) {
				for (k=0;k<5;k++) { if(enemy[k].s==1) {       //updates only if object is alive (s==1)
					if (countx<=92 && wave2==0) {
						enemy[k].x = enemy[k].x +1;
					}
					countx++;
					if (countx >92 && wave2==0) {wave2=1; countx=0;}
					if (wave2==1) {
						for (j=0;j<5;j++) {
							enemy[j].y=enemy[j].y+1;
							
						}
						wave2=2;  
						countx=0;
						county++;
					} 
					if (countx <=92 && wave2==2) {
						enemy[k].x= enemy[k].x-1;
					}
					countx++;
					if (countx >= 92 && wave2==2 ) {wave2=3; countx=0;}
					if (wave2==3) {
						for (j=0;j<5;j++) {
							enemy[j].y=enemy[j].y+1;
							
						}
						wave2=0; county++;
					}
					trainWreckL = xShip-enemy[j].x;												//enemy within left boundary of ship
					trainWreckR = enemy[j].x - xShip;											//enemy within right boundary of ship
					
					if( (enemy[j].y >= 176) &&
													(((trainWreckL <24)&&(trainWreckL >0) )||((trainWreckR < 30)&&(trainWreckR > 0))) ){
						enemy[j].s = 2;
						DEATH();								
						userDeath++;
					}	
					if (enemy[k].y>=210) {enemy[k].s=0;}
				}
			}
				//fleet 2
			if (county==24 || enemycount==10) {enemy[5].s=1; wave3=1;} //activate the bigger ships once there is room vertically, e.i. check if y coordinate has been met
			if (countx2==24) {enemy[6].s=1;}
			if (countx2==48 ) {enemy[7].s=1;}
			if (countx2==72) {enemy[8].s=1;}
			if (countx2==96) {enemy[9].s=1;}
	
			//if (enemy[5].x>=196) {wave2big=1;} //once the enemies get to the edge of the screen, set a flag (wave big) to one
			if (countx2>=146) {wave2big=1;}
	    for (k=5;k<10;k++) {
				if(wave3==1 && k==5) {countx2++;}	
				if(enemy[k].s==1 && wave2big==0) {  //update coordinates for new ships for wave 2 only if they become active (due to above code) and if max x coordinate hasn't been set
				enemy[k].x=enemy[k].x+1;	}
        	
			 if(enemy[k].y>=210) {enemy[k].s=0;} //enemy dead if off the screen vertically, we don't care if horizontally
			 if(enemy[k].s==1 && wave2big==1) {
				 if(k==5 || k==6) {enemy[k].x=enemy[k].x-1; enemy[k].y=enemy[k].y+1;}
				 if(k==8 || k==9) {enemy[k].x=enemy[k].x+1; enemy[k].y=enemy[k].y+1;}
				 if(k==7 && enemy[k].y<=100) {enemy[k].y=enemy[k].y+1;} 
			 }
			 
		 }
			 			 //fleet 3
			if (county==48 || enemycount==10) {enemy[10].s=1; wave4=1;} //activate the bigger ships once there is room vertically, e.i. check if y coordinate has been met
			if (countx3==24) {enemy[11].s=1;}
			if (countx3==48 ) {enemy[12].s=1;}
			if (countx3==72) {enemy[13].s=1;}
			if (countx3==96) {enemy[14].s=1;}
			 
				if (countx3>=146) {wave3big=1;}
	    for (k=10;k<15;k++) {
				if(wave4==1 && k==10) {countx3++;}	
				if(enemy[k].s==1 && wave3big==0) {  //update coordinates for new ships for wave 2 only if they become active (due to above code) and if max x coordinate hasn't been set
				enemy[k].x=enemy[k].x-1;	}
        	
			 if(enemy[k].y>=210) {enemy[k].s=0;} //enemy dead if off the screen vertically, we don't care if horizontally
			 if(enemy[k].s==1 && wave3big==1) {
         if(k==10) {if(enemy[k].y<120 && enemy[k].x==50) {enemy[k].y=enemy[k].y+1;}
				          if(enemy[k].y==120 && enemy[k].x<130) {enemy[k].x=enemy[k].x+1;}
									if(enemy[k].y>64 && enemy[k].x==130) {enemy[k].y=enemy[k].y-1;}
									if(enemy[k].y==64 && enemy[k].x>50) {enemy[k].x=enemy[k].x-1;}}
				
			   if(k==14) {if(enemy[k].y<120 && enemy[k].x==246) {enemy[k].y=enemy[k].y+1;}
				          if(enemy[k].y==120 && enemy[k].x>166) {enemy[k].x=enemy[k].x-1;}
									if(enemy[k].y>64 && enemy[k].x==166) {enemy[k].y=enemy[k].y-1;}
									if(enemy[k].y==64 && enemy[k].x<246) {enemy[k].x=enemy[k].x+1;}}
				 if(k==11 || k==13 || k==12) {enemy[k].y=enemy[k].y+1;}
			 }
									
			 } 
			 
			 
			 
			 
			
			
			
		}
		
	
										
										
	///////////////////////////////////////////////////////////////////////Update User missiles////////////////////////////////////////////////////////////////////////////////////////////////
			for(i=0;i<100;i++){														
					if(missile[i].s){
						  missile[i].y = missile[i].y - 2;							//if missile is active, move up the screen
							if(missile[i].y < 18 ){
									missile[i].s = 0;																				//if the missile has moved off the screen, deactivate it
									LCD_DrawBMP(UmissileErase,missile[i].x,missile[i].y);		//cover up with black
							      }
							
										
												
							
//////////////////////////////////////////////////////////////////Test for Enemy-Missile Collisions (small aliens)///////////////////////////////////////////////////////////////////////////////////////
										for(k=0;k<wavesize;k++){																																						      //(missile:11x15, enemy: 24x24)
										crashTestY = ((enemy[k].y + 24) - missile[i].y);											//difference in y-coordinates
										crashTestXR = (missile[i].x - enemy[k].x);													//distance of missile from right border of alien
										crashTestXL = (enemy[k].x - missile[i].x);													//distance of missile from left border of alien
										
											if   ( ( (crashTestY <5) && (crashTestY > 0) ) &&
														( (	(crashTestXR < 24) && (crashTestXR > 0 ) ) || ( (crashTestXL < 11)&&(crashTestXL > 0) ) ) ){
															enemy[k].s = 2;
														}
										
									 
					          }
					 }
			}
			
			
			
/////////////////////////////////////////////////////////////////////Test for Enemy-User Collisions///////////////////////////////////////////////////////////////////////////////////////////////////
									/*	for(k=0;k<5;k++){
											trainWreckL = xShip-enemy[k].x;												//enemy within left boundary of ship
											trainWreckR = enemy[k].x - xShip;											//enemy within right boundary of ship
											
											if( (enemy[k].y >= 176) &&
													(((trainWreckL <24)&&(trainWreckL >0) )||((trainWreckR < 30)&&(trainWreckR > 0))) ){
														enemy[k].s = 2;
														DEATH();								
														userDeath++;
													}		*/		
//////////////////////////////////////////////////////////////////////////Activate New Missile/////////////////////////////////////////////////////////////////////////////////////////////
					if(newMissile==3){
							while(missile[notActiveSlot].s == 1){												//find a non-active missile in the array
									if(notActiveSlot == 99){notActiveSlot = 0;}										//wrap around if at end of array
									notActiveSlot++;																							//check next slot
								}
							missile[notActiveSlot].x = xShip + 10;												//missile(11x15) aligned to center of ship
							missile[notActiveSlot].y = 185;																//missile firing out 200 - 15
							missile[notActiveSlot].s = 1;																//activate
							Timer2A_Start();																								//arm sound
							newMissile=0;                                                 //reset button count
								tester++;
							
					}
					
						 
						 
						
	///////////////////////////////////////////////////////Update Enemy Missiles/////////////////////////////////////////////////////////////////////////////////////////////////////////
					for(i=0;i<100;i++){
								if(emissile[i].s==1){
										emissile[i].y = emissile[i].y + 2;
										if(emissile[i].y > 210){
												emissile[i].s = 0;
												LCD_DrawBMP(UmissileErase,emissile[i].x,emissile[i].y);
										}
									}
								}
									

///////////////////////////////////////////////////////////////////////Test for User Missile Collisions////////////////////////////////////////////////////////////////////////////////////
					for(i=0;i<100;i++){
								if((emissile[i].s ==1)&&(emissile[i].y >= 185)&&
										((((emissile[i].x - xShip)<30)&&((emissile[i].x - xShip)>0))|| 
													(((xShip- emissile[i].x)<11)&&((xShip-emissile[i].x)>0)))){
										emissile[i].s = 0;
										DEATH();
										userDeath++;
							 }
					}


////////////////////////////////////////////////////////////////////////New Enemy Missiles////////////////////////////////////////////////////////////////////////////////////////////////////
//activate new enemy missiles
					for(k=0;k<wavesize;k++){
									if((enemy[k].s)&&(enemy[k].wait == 1)){																	//alive and finished (.wait == 1 means countdown done)
															while(emissile[notActiveSlotE].s == 1){												//find a non-active enemy missile slot in array
																	if(notActiveSlotE == 99){notActiveSlotE = 0;}							//wrap around if at end of array
																	else notActiveSlotE++;																			//check next slot
															 }
												emissile[notActiveSlotE].x = enemy[k].x + (enemy[k].w / 2);    //center horizontal positioning of missile on enemy
												emissile[notActiveSlotE].y = enemy[k].y + enemy[k].h;						//get correct vertical positioning for missile
												emissile[notActiveSlotE].s = 1;																	//activate missile
												enemy[k].wait = 0;																							//signifying missile fired, reaady for new wait time
									}
					}


//loading enemies that just fired with new wait times
					for(k=0;k<wavesize;k++){
									if((enemy[k].s)&&(enemy[k].wait == 0)){					//alive and not currently waiting to fire (.wait == 0 means need new time)
												j = (Random()%60);											//get random number from 0-30
												if(j < 20){j=20;}												//minimum # 20 (3 shots per second max firing)
												enemy[k].wait = j;
									}
					}

	

	/////////////////////////////////////////////////////////////////////enemy missile printing//////////////////////////////////////////////////////////////////////////////////////////////
			for(i=0;i<100;i++){
					if(emissile[i].s == 1){
						LCD_DrawBMP(enemyMissile,emissile[i].x,emissile[i].y);}}
					/*else if ((emissile[i].s == 0)&&(emissile[i].b==0)){
							LCD_DrawBMP(UmissileErase,emissile[i].x,emissile[i].y);}
							emissile[i].b = 1;
					}*/
				
	

						 
//////////////////////////////////////////////////////////////////////////////missile printing///////////////////////////////////////////////////////////////////////////////////////////
			for(i=0;i<100;i++){
				if(missile[i].s){
					LCD_DrawBMP(userMissile,missile[i].x,missile[i].y);							//print if missile is active
			   	}
				}


				
					

            
    
             
						
								
								
								

///////////////////////////////////////////////////////////////////////////enemy ship printing///////////////////////////////////////////////////////////////////////////////////////
/////////////ship printing for wave 1
				if(wave==10) {
			for (k=0;k<5;k++) {
				if (enemy[k].s ==1) {
			LCD_DrawBMP(AlienEnemyBig, enemy[k].x,enemy[k].y); }
				if (enemy[k].s ==2 &&enemy[k].b ==0) {
			LCD_DrawBMP(Explosion1, enemy[k].x,(enemy[k].y)); LCD_DrawBMP (Explosion1, enemy[k].x, enemy[k].y);
			LCD_DrawBMP(Explosion1, enemy[k].x,(enemy[k].y)); LCD_DrawBMP (Explosion1,enemy[k].x, enemy[k].y);
      enemy[k].s=0;		enemy[k].b=1;
				} 
				if (enemy[k].s ==0 && enemy[k].e ==0) {
			LCD_DrawBMP(ExplosionBlack, enemy[k].x,(enemy[k].y));
				enemy[k].e=1;}
		}


			 for (k=0;k<5;k++) {
				if(enemy[k].s==0 && enemy[k].c==0) {enemycount++; enemy[k].c=1;} //count enemies if s=0 and c=0
			}
			if (enemycount==5) {wave=21;} //new wave is all five enemies are "dead"
		} 
	
/////////////Ship printing for wave 2
				if(wave==20) {
			for (k=0;k<5;k++) {
				if (enemy[k].s ==1) {
			LCD_DrawBMP(AlienEnemySmall, enemy[k].x,enemy[k].y); }
				if (enemy[k].s ==2 && enemy[k].b ==0) {
			LCD_DrawBMP(Explosion1, enemy[k].x,(enemy[k].y)); LCD_DrawBMP (Explosion1,enemy[k].x, enemy[k].y);
			LCD_DrawBMP(Explosion1, enemy[k].x,(enemy[k].y)); LCD_DrawBMP (Explosion1,enemy[k].x, enemy[k].y);
      enemy[k].s=0;		enemy[k].b=1;
				} 
				if (enemy[k].s ==0 && enemy[k].e==0) {                               //once explosion eraser is printed, set the s to zero and e to one
			LCD_DrawBMP(ExplosionBlack, enemy[k].x,(enemy[k].y));                     
				enemy[k].e=1;}
		}
			for(k=5;k<10;k++) {
				if(enemy[k].s==1) {
			 LCD_DrawBMP(AlienEnemyBig, enemy[k].x,enemy[k].y); }
	      if (enemy[k].s ==2 && enemy[k].b ==0) {
			LCD_DrawBMP(Explosion1, enemy[k].x,(enemy[k].y)); LCD_DrawBMP (Explosion1,enemy[k].x, enemy[k].y);
			LCD_DrawBMP(Explosion1, enemy[k].x,(enemy[k].y)); LCD_DrawBMP (Explosion1,enemy[k].x, enemy[k].y);
      enemy[k].s=0;		enemy[k].b=1;
				} 
				if (enemy[k].s ==0 && enemy[k].e==0) {                               //once explosion eraser is printed, set the s to zero and e to one
			LCD_DrawBMP(ExplosionBlack, enemy[k].x, enemy[k].y);                     
				enemy[k].e=1;}}
				
	

			for (k=0;k<10;k++) { 
				if(enemy[k].s==0 && enemy[k].c==0) {enemycount++; enemy[k].c=1;} //count enemy if s=0 and c=0
			}
			
			
			if (enemycount==20) {wave=31;}  //new wave if all ten enemies are "dead"
		
				
		
					for(k=10;k<15;k++) {
				if(enemy[k].s==1) {
			 LCD_DrawBMP(AlienEnemyBig, enemy[k].x,enemy[k].y); }
	      if (enemy[k].s ==2 && enemy[k].b ==0) {
			LCD_DrawBMP(Explosion1, enemy[k].x,(enemy[k].y)); LCD_DrawBMP (Explosion1,enemy[k].x, enemy[k].y);
			LCD_DrawBMP(Explosion1, enemy[k].x,(enemy[k].y)); LCD_DrawBMP (Explosion1,enemy[k].x, enemy[k].y);
      enemy[k].s=0;		enemy[k].b=1;
				} 
				if (enemy[k].s ==0 && enemy[k].e==0) {                               //once explosion eraser is printed, set the s to zero and e to one
			LCD_DrawBMP(ExplosionBlack, enemy[k].x, enemy[k].y);                     
				enemy[k].e=1;}} }
				
			}					//close semaphore
	}								//close while loop
} 							//close main
/*******************************************************************************
* Function Name  : Thermometer_Temperature
* Description    : Displays the temperature in Celsius and fahrenheit degree.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Thermometer_Temperature(void)
{
  uint32_t i = 0;
  
  while(ReadKey() != NOKEY)
  {
  }

  if(I2C_LM75_Status() == SUCCESS)
  {
    /* Disable the JoyStick Interrupts */
    IntExtOnOffConfig(DISABLE);

    /* Clear the LCD */
    LCD_Clear(White);
  
    /* Set the Icon display window */ 
    LCD_SetDisplayWindow(150, 210, 64, 84);
 
    /* Display the Thermometer icon */
    LCD_DrawBMP(0x0062A300);

    /* Disable LCD Window mode */
    LCD_WindowModeDisable();

    /* Set the Back Color */
    LCD_SetBackColor(Red);
    /* Set the Text Color */
    LCD_SetTextColor(White);

    LCD_DisplayStringLine(Line2, "     Temperature    ");

    /* Set the Back Color */
    LCD_SetBackColor(Blue);
    /* Set the Text Color */
    LCD_SetTextColor(Green);

    /* Wait until no key is pressed */
    while(ReadKey() != NOKEY)
    {
    }
    /* Wait until a key is beiing pressed */
    while(ReadKey() == NOKEY)
    {
      /* Get double of Temperature value */
      TempCelsius_Value = I2C_LM75_Temp_Read();

      if(TempCelsius_Value <= 1023)
      {
        /* Positive temperature measured */
        TempCelsius_Display[5] = '+';
        TempFahrenheit_Display[5] = '+'; 
      }
      else
      {
        /* Negative temperature measured */
        TempCelsius_Display[5] = '-'; 
        TempFahrenheit_Display[5] = '-'; 
        /* Remove temperature value sign */
        TempCelsius_Value = 0x800 - TempCelsius_Value;
      }

      /* Calculate temperature digits in °C */
      Temp_Decimal = ((TempCelsius_Value & 7) * 1000 / 8);
      TempCelsius_Display[10] = (Temp_Decimal / 100) + 0x30;
      TempCelsius_Display[11] = ((Temp_Decimal % 100) / 10) + 0x30;
      TempCelsius_Display[12] = ((Temp_Decimal % 100) % 10) + 0x30;
      TempCelsius_Value >>= 3;
      TempCelsius_Display[6] = (TempCelsius_Value / 100) + 0x30;
      TempCelsius_Display[7] = ((TempCelsius_Value % 100) / 10) + 0x30;
      TempCelsius_Display[8] = ((TempCelsius_Value % 100) % 10) + 0x30;

      /* Convert temperature °C to Fahrenheit */
      Temp_Value_Fahrenheit = ((9 * ((TempCelsius_Value * 1000) + Temp_Decimal)) / 5) + 32000;

      /* Calculate temperature digits in °F */
      TempFahrenheit_Display[6] = (Temp_Value_Fahrenheit / 100000) + 0x30;
      TempFahrenheit_Display[7] = ((Temp_Value_Fahrenheit % 100000) /10000) + 0x30;
      TempFahrenheit_Display[8] = ((Temp_Value_Fahrenheit % 100000) %10000/1000) + 0x30;
      TempFahrenheit_Display[10] = ((((Temp_Value_Fahrenheit % 100000) %10000) %1000) /100) + 0x30;
      TempFahrenheit_Display[11] = (((((Temp_Value_Fahrenheit % 100000) %10000) %1000) %100) /10) + 0x30;
      TempFahrenheit_Display[12] = (((((Temp_Value_Fahrenheit % 100000) %10000) %1000) %100) %10) + 0x30;

      /* Display Fahrenheit value on LCD */
      for(i = 0; i < 20; i++)
      {
        LCD_DisplayChar(Line7, (319 - (16 * i)), TempCelsius_Display[i]);
        LCD_DisplayChar(Line8, (319 - (16 * i)), TempFahrenheit_Display[i]);
      }
    }
  }