Li Ruofan 201199450

Dependencies:   mbed Gamepad Joystick

Revision:
8:b4a2954dd74f
Parent:
6:cbd9e1f26a10
diff -r e3844250b77d -r b4a2954dd74f homepage/homepage.cpp
--- a/homepage/homepage.cpp	Fri May 15 22:23:22 2020 +0000
+++ b/homepage/homepage.cpp	Sat May 16 17:26:10 2020 +0000
@@ -1,10 +1,10 @@
 #include "homepage.h"
 
-Homepage::homepage(){
+Homepage::Homepage(){
     
 }
 
-Homepage::~homepage()
+Homepage::~Homepage()
 {}
 
 void Homepage::welcome(N5110 &lcd,BusOut &output,Bgm &bgm) 
@@ -12,8 +12,6 @@
     //show "Spaceship"
     lcd.printString("   Spaceship   ",0,1);  
     lcd.refresh();
-    drawEverything(lcd);
-    lcd.refresh();
     output=0b000000;
     
     //welcome bgm
@@ -33,23 +31,22 @@
     output=0b111111;
     lcd.clear();
 }
-void Homepage::homepage(N5110 &lcd,InterruptIn &buttonA, InterruptIn &start,int *score,int n)
+void Homepage::homepage(N5110 &lcd,InterruptIn &buttonB, InterruptIn &start,int *score,int n)
 {
     //show Homepage and check the pressed button 
     lcd.refresh();
     while(1){
         
         lcd.printString(" Press Start to start ",0,0);
-        lcd.printString(" A Rules",0,2);
+        lcd.printString(" Press B to Rules",0,2);
         lcd.refresh();
         
-        if(buttonA){
+        if(buttonB){
             wait(0.5f);
             lcd.clear(); 
-            //show the game rule
-            rules(lcd,buttonA);
+            rules(lcd,buttonB);
         }else if(start){
-            lcd.clear(); //start the game
+            lcd.clear(); 
             break;
         }
     }
@@ -62,30 +59,8 @@
     sprintf(buffer,"%d",score);
     lcd.printString(buffer,0,0);
 }
-void Homepage::drawEverything(N5110 &lcd){
-    
-   int Spaceship[15][10] = {
-   0,0,0,0,0,0,0,0,0,0,
-   0,0,0,0,1,1,0,0,0,0,
-   0,0,0,0,1,1,0,0,0,0,
-   0,0,1,1,0,0,1,1,0,0,
-   0,1,1,1,1,1,1,1,1,0,
-   0,1,1,1,1,1,1,1,1,0,
-   1,1,1,1,1,1,1,1,1,1,
-   1,1,1,1,1,1,1,1,1,1,
-   1,1,1,1,1,1,1,1,1,1,
-   1,1,1,1,1,1,1,1,1,1,
-   1,1,1,1,1,1,1,1,1,1,
-   1,1,1,1,0,0,1,1,1,1,
-   0,1,1,1,0,0,1,1,1,0,
-   0,0,1,1,0,0,1,1,0,0,
-   0,0,0,1,1,1,1,0,0,0,
-   0,0,0,0,0,0,0,0,0,0,
-    //draw spaceship
-    Bitmap sprite2(_Spaceship, 16, 10); 
-    sprite2.render(lcd, 28, 28); 
-}
-void Homepage::rules(N5110 &lcd,InterruptIn &buttonA) {
+
+void Homepage::rules(N5110 &lcd,InterruptIn &buttonB) {
     //show game rules
     while(1) {
         lcd.clear();
@@ -102,7 +77,7 @@
         }
     }
 }
-int homepage::again(N5110 &lcd,int score,InterruptIn &buttonX,InterruptIn &buttonY){
+int Homepage::again(N5110 &lcd,int score,InterruptIn &buttonX,InterruptIn &buttonY){
     
     lcd.clear();
     while(1){
@@ -123,7 +98,6 @@
                 return 0;
             }
         }else{
-            // player doesn't have enough scores , so game over directly
             lcd.printString("Fail",0,1);
             lcd.printString("Press Y return",0,2);
             lcd.refresh();