ELEC2645 (2018/19) / Mbed 2 deprecated 2645_Project_SiutingWong201186503

Dependencies:   mbed

Revision:
6:a0f3dbbc8d33
Parent:
4:fcd80b40f257
Child:
7:193c0fd7afdd
diff -r 53380b940833 -r a0f3dbbc8d33 main.cpp
--- a/main.cpp	Wed May 08 21:01:54 2019 +0000
+++ b/main.cpp	Wed May 08 23:42:32 2019 +0000
@@ -16,13 +16,14 @@
 #define WALL_WIDTH 2
 #define WALL_GAP 10
 #define AVENGER_SIZE 2
-#define STONE_SIZE 1
+#define STONE_SIZE 2
 #define SPEED 2
 
 /////////////// structs /////////////////
 struct UserInput {
     Direction d;
     float mag;
+    Vector2D mapped_coord;
 };
 /////////////// objects ///////////////
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
@@ -38,16 +39,14 @@
 
 ///////////// functions ////////////////
 int main() {
-    int fps = 10;
-    int avenger_score = eng.get_score();
+    int fps = 8;
     
     init();     // initialise and then display welcome screen...
     welcome();
     render();
     wait(1.0f/fps);  // and wait for one frame period
     
-    while (avenger_score >= 0) {
-        int avenger_score = eng.get_score();
+    while (eng.get_score() >= 0) {
         eng.read_input(pad);
         eng.update(pad);
         render();
@@ -70,9 +69,15 @@
     
     while ( pad.check_event(Gamepad::START_PRESSED) == false) {
         lcd.clear();
-        lcd.printString("Eternity Stone",0,1);
+        lcd.printString("Eternity Stone",0,0);
+        lcd.drawSprite(25,8,25,32,(int *)Avenger0);
         lcd.refresh();
-        wait(0.1);
+        wait(0.5);
+        lcd.clear();
+        lcd.printString("Eternity Stone",0,0);
+        lcd.drawSprite(25,8,25,32,(int *)Avenger1);
+        lcd.refresh();
+        wait(0.5);
     }
 }
 
@@ -88,19 +93,92 @@
     lcd.clear();
         lcd.printString("Endgame",12,1);
         lcd.refresh();
-    pad.tone(587.3,0.9);
-    pad.tone(0.0,0.1);
-    pad.tone(587.3,0.9);
-    pad.tone(0.0,0.1);
-    pad.tone(587.3,0.9);
-    pad.tone(0.0,0.1);
-    pad.tone(698.5,0.6);
-    pad.tone(659.3,0.3);
-    pad.tone(0.0,0.1);
-    pad.tone(659.3,0.6);
-    pad.tone(587.3,0.3);
-    pad.tone(0.0,0.1);
-    pad.tone(554.4,0.6);
-    pad.tone(587.3,0.3);
-    wait(0.1);
-}
\ No newline at end of file
+    pad.tone(587.3,0.63);
+    wait(0.63);
+    pad.tone(0.0,0.06);
+    wait(0.06);
+    pad.tone(587.3,0.63);
+    wait(0.63);
+    pad.tone(0.0,0.06);
+    wait(0.06);
+    pad.tone(587.3,0.63);
+    wait(0.63);
+    pad.tone(0.0,0.06);
+    wait(0.06);
+    pad.tone(698.5,0.42);
+    wait(0.42);
+    pad.tone(659.3,0.21);
+    wait(0.21);
+    pad.tone(0.0,0.06);
+    wait(0.06);
+    pad.tone(659.3,0.42);
+    wait(0.42);
+    pad.tone(587.3,0.21);
+    wait(0.21);
+    pad.tone(0.0,0.06);
+    wait(0.06);
+    pad.tone(587.3,0.42);
+    wait(0.42);
+    pad.tone(554.4,0.21);
+    wait(0.21);
+    pad.tone(587.3,0.42);
+    wait(0.42);
+}
+
+const int Avenger0[25][32] =
+{
+    { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+    { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0 },
+    { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0 },
+    { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0 },
+    { 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0 },
+    { 0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,1,1,1,1,1,0,0,0,0,0,1,0,0,0 },
+    { 0,0,0,1,0,0,0,0,0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