void drawGameOver(int score, int time){ LCD_DrawFilledRect(boardX,boardY,boardLen,boardLen,BLACK); LCD_SetTextColor(255,255,240); LCD_Goto(30,5); printf("GAME OVER"); LCD_Goto(23,8); printf("Score:"); LCD_Goto(29,8); LCD_PrintInteger(score); LCD_Goto(23,10); printf("Time:"); LCD_Goto(28,10); LCD_PrintInteger(time); LCD_Goto(29,19); printf("Play Again?"); LCD_DrawRect(170,166,72,16,WHITE); }
//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; } } }
void eraseTime(void){ LCD_Goto(2,13); LCD_SetTextColor(0,0,0); LCD_PrintInteger(99999999); }
void writeTime(int time){ LCD_Goto(2,13); LCD_SetTextColor(255,255,240); LCD_PrintInteger(time); }
void writeHighscore(int score){ LCD_Goto(2,16); LCD_SetTextColor(255,255,240); LCD_PrintInteger(score); }
void eraseScore(void){ LCD_Goto(2,10); LCD_SetTextColor(0,0,0); LCD_PrintInteger(99999999); }