Final Trivia Game Code

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed wave_player

Fork of TriviaGame by Michael Balourdas

Revision:
4:55bb76d28153
Parent:
3:9842b3f1d809
--- a/main.cpp	Sun Dec 11 03:09:22 2016 +0000
+++ b/main.cpp	Tue Dec 13 18:00:58 2016 +0000
@@ -53,7 +53,8 @@
      do {       /* generate digits in reverse order */
          s[i++] = n % 10 + '0';   /* get next digit */
      } while ((n /= 10) > 0);     /* delete it */
-
+     
+ 
  }
 
 int main()
@@ -61,7 +62,7 @@
     srand(time(NULL));
     while (true){
         answer = 1;
-        for (int i=0; i<10; i++){
+        for (int i=0; i<16; i++){
             v.push_back(i+1);
         }
         check = 0;
@@ -73,7 +74,7 @@
         if (mode == 1){
             uLCD.cls();
             uLCD.media_init();
-            uLCD.set_sector_address(0x0000, 0x001D);
+            uLCD.set_sector_address(0x0000, 0x009F);
             uLCD.display_image(0,0);
             wait(2);
             uLCD.cls();
@@ -81,7 +82,6 @@
             if (nScore > nHighScore){
             nHighScore = nScore;
             uLCD.printf("NEW NORMAL\n HIGH SCORE!\n %d", nHighScore);
-            
             wait(2);
         }
         itoa(nHighScore, nHigh);
@@ -91,7 +91,7 @@
         if (mode == 2){
             uLCD.cls();
             uLCD.media_init();
-            uLCD.set_sector_address(0x0000, 0x001D);
+            uLCD.set_sector_address(0x0000, 0x009F);
             uLCD.display_image(0,0);
             wait(2);
             uLCD.cls();
@@ -101,7 +101,6 @@
             uLCD.printf("NEW TIMED\n HIGH SCORE!\n %d", tHighScore);
             wait(2);
         }
-        
         itoa(tHighScore, tHigh);
         pc.puts(tHigh);
         uLCD.printf("\nClick New Game");
@@ -109,7 +108,7 @@
         if (mode == 4){
             uLCD.cls();
             uLCD.media_init();
-            uLCD.set_sector_address(0x0000, 0x001D);
+            uLCD.set_sector_address(0x0000, 0x009F);
             uLCD.display_image(0,0);
             wait(2);
             uLCD.cls();
@@ -165,8 +164,8 @@
                     break;
                     }
                     }
-            if (mode == 4){
-                if (counter > 3){
+            if (mode == 1){
+                if (counter > 6){
                     break;
                     }
                 }
@@ -178,9 +177,10 @@
             v.erase(v.begin()+index);
             check = 0;
             uLCD.cls();
-            if (mode == 1){
-                uLCD.printf("Score: %d", nScore);
+            if (mode == 4){
+                uLCD.printf("Score: %d", cScore);
             }
+            
             wait(1);
             if (question == 1){
                 value = 0;
@@ -197,7 +197,7 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -205,7 +205,7 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter +1;
@@ -216,7 +216,7 @@
                         //play correct image
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.set_sector_address(0x0000, 0x001D);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/right_taught.wav","r");
@@ -244,7 +244,7 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -252,7 +252,7 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter+1;
@@ -275,7 +275,7 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -283,7 +283,7 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter +1;
@@ -294,7 +294,7 @@
                         //play correct image
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.set_sector_address(0x0000, 0x001D);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/right_taught.wav","r");
@@ -323,7 +323,7 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -331,7 +331,7 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter+1;
@@ -354,7 +354,7 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -362,7 +362,7 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter +1;
@@ -373,7 +373,7 @@
                         //play correct image
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.set_sector_address(0x0000, 0x001D);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/right_taught.wav","r");
@@ -402,7 +402,7 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -410,7 +410,7 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter+1;
@@ -433,7 +433,7 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -441,7 +441,7 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter +1;
@@ -452,9 +452,88 @@
                         //play correct image
                         uLCD.cls();
                         uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/right_taught.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 1){
+                        nScore = nScore+1;
+                        }
+                        if (mode == 2){
+                        tScore = tScore+1;
+                        }
+                        if (mode == 4){
+                        cScore = cScore+1;
+                        }
+                        //uLCD.printf("Score: %d", Score);
+                        wait(1);
+                        if (mode == 1){
+                        answer = 1;
+                        }
+                            counter=counter+1;
+                        check = 1;
+                        }
+                    if (value == 8){
+                        //play game over
+                        uLCD.cls();
+                        uLCD.media_init();
                         uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter+1;
+                        check = 1;
+                    }
+                }
+            }
+            if (question == 5){
+                value = 0;
+                uLCD.cls();
+                uLCD.locate(1,2);
+                uLCD.printf("Which song is by the Rolling Stones?\n\n\n");
+                uLCD.printf("1) Paint It Black\n");
+                uLCD.printf("2) Feel For \nThe Devil\n");
+                uLCD.printf("3) Let It Be\n");
+                while (check == 0){
+                    int value=mpr121.read(0x00);
+                    value +=mpr121.read(0x01)<<8;
+                    if (value == 4){
+                        //play game over
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter +1;
+                        
+                        check = 1;
+                        }
+                    if (value == 2){
+                        //play correct image
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/right_taught.wav","r");
                         waver.play(wave_file);
                         fclose(wave_file);
@@ -481,7 +560,38 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter+1;
+                        check = 1;
+                    }
+                }
+            }
+             if (question == 6){
+                value = 0;
+                uLCD.cls();
+                uLCD.locate(1,2);
+                uLCD.printf("Where was Hitler born?\n\n\n");
+                uLCD.printf("1) Poland\n");
+                uLCD.printf("2) Germany\n");
+                uLCD.printf("3) Austria\n");
+                while (check == 0){
+                    int value=mpr121.read(0x00);
+                    value +=mpr121.read(0x01)<<8;
+                    if (value == 2){
+                        //play game over
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -489,7 +599,55 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter +1;
+                        
+                        check = 1;
+                        }
+                    if (value == 8){
+                        //play correct image
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/right_taught.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
                         if (mode == 1){
+                        nScore = nScore+1;
+                        }
+                        if (mode == 2){
+                        tScore = tScore+1;
+                        }
+                        if (mode == 4){
+                        cScore = cScore+1;
+                        }
+                        //uLCD.printf("Score: %d", Score);
+                        wait(1);
+                        if (mode == 1){
+                        answer = 1;
+                        }
+                            counter=counter+1;
+                        check = 1;
+                        }
+                    if (value == 4){
+                        //play game over
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter+1;
@@ -497,22 +655,22 @@
                     }
                 }
             }
-            if (question == 5){
+             if (question == 7){
                 value = 0;
                 uLCD.cls();
                 uLCD.locate(1,2);
-                uLCD.printf("Which song is by the Rolling Stones?\n\n\n");
-                uLCD.printf("1) Paint It Black\n");
-                uLCD.printf("2) Feel For \nThe Devil\n");
-                uLCD.printf("3) Let It Be\n");
+                uLCD.printf("The best selling\nmusic single of all time is?\n\n\n");
+                uLCD.printf("1) Billie Jean\n");
+                uLCD.printf("2) White Christmas\n");
+                uLCD.printf("3) Candle in the \nWind\n");
                 while (check == 0){
                     int value=mpr121.read(0x00);
                     value +=mpr121.read(0x01)<<8;
-                    if (value == 4){
+                    if (value == 2){
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -520,20 +678,99 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter +1;
                         
                         check = 1;
                         }
-                    if (value == 2){
+                    if (value == 8){
                         //play correct image
                         uLCD.cls();
                         uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/right_taught.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 1){
+                        nScore = nScore+1;
+                        }
+                        if (mode == 2){
+                        tScore = tScore+1;
+                        }
+                        if (mode == 4){
+                        cScore = cScore+1;
+                        }
+                        //uLCD.printf("Score: %d", Score);
+                        wait(1);
+                        if (mode == 1){
+                        answer = 1;
+                        }
+                            counter=counter+1;
+                        check = 1;
+                        }
+                    if (value == 4){
+                        //play game over
+                        uLCD.cls();
+                        uLCD.media_init();
                         uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter+1;
+                        check = 1;
+                    }
+                }
+            }
+             if (question == 8){
+                value = 0;
+                uLCD.cls();
+                uLCD.locate(1,2);
+                 uLCD.printf("What is the \ncurrency of \nJapan?\n\n\n");
+                uLCD.printf("1) Pounds\n");
+                uLCD.printf("2) Yen\n");
+                uLCD.printf("3) Riki\n");
+                while (check == 0){
+                    int value=mpr121.read(0x00);
+                    value +=mpr121.read(0x01)<<8;
+                    if (value == 2){
+                        //play game over
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter +1;
+                        
+                        check = 1;
+                        }
+                    if (value == 4){
+                        //play correct image
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/right_taught.wav","r");
                         waver.play(wave_file);
                         fclose(wave_file);
@@ -560,7 +797,7 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -568,7 +805,7 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter+1;
@@ -576,22 +813,22 @@
                     }
                 }
             }
-             if (question == 6){
+             if (question == 9){
                 value = 0;
                 uLCD.cls();
                 uLCD.locate(1,2);
-                uLCD.printf("Where was Hitler born?\n\n\n");
-                uLCD.printf("1) Poland\n");
-                uLCD.printf("2) Germany\n");
-                uLCD.printf("3) Austria\n");
+                uLCD.printf("Who was Harry \nHoudini?\n\n\n");
+                uLCD.printf("1)An Escape Artist\n");
+                uLCD.printf("2)Fighter Pilot in WWII\n");
+                uLCD.printf("3) Harry Potter's Cousin\n");
                 while (check == 0){
                     int value=mpr121.read(0x00);
                     value +=mpr121.read(0x01)<<8;
-                    if (value == 2){
+                    if (value == 4){
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -599,18 +836,18 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter +1;
                         
                         check = 1;
                         }
-                    if (value == 8){
+                    if (value == 2){
                         //play correct image
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.set_sector_address(0x0000, 0x001D);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/right_taught.wav","r");
@@ -635,42 +872,11 @@
                             counter=counter+1;
                         check = 1;
                         }
-                    if (value == 4){
+                    if (value == 8){
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
-                        uLCD.display_image(0,0);
-                        FILE *wave_file;   
-                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
-                        waver.play(wave_file);
-                        fclose(wave_file);
-                        wait(1);
-                        uLCD.cls();
-                        if (mode == 1){
-                        answer = 0;
-                        }
-                        counter = counter+1;
-                        check = 1;
-                    }
-                }
-            }
-             if (question == 7){
-                value = 0;
-                uLCD.cls();
-                uLCD.locate(1,2);
-                uLCD.printf("The best selling\nmusic single of all time is?\n\n\n");
-                uLCD.printf("1) Billie Jean\n");
-                uLCD.printf("2) White Christmas\n");
-                uLCD.printf("3) Candle in the \nWind\n");
-                while (check == 0){
-                    int value=mpr121.read(0x00);
-                    value +=mpr121.read(0x01)<<8;
-                    if (value == 2){
-                        //play game over
-                        uLCD.cls();
-                        uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -678,47 +884,30 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
-                        counter = counter +1;
-                        
+                        counter = counter+1;
                         check = 1;
-                        }
-                    if (value == 8){
-                        //play correct image
-                        uLCD.cls();
-                        uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x005E);
-                        uLCD.display_image(0,0);
-                        FILE *wave_file;   
-                        wave_file=fopen("/sd/sounds/right_taught.wav","r");
-                        waver.play(wave_file);
-                        fclose(wave_file);
-                        wait(1);
-                        uLCD.cls();
-                        if (mode == 1){
-                        nScore = nScore+1;
-                        }
-                        if (mode == 2){
-                        tScore = tScore+1;
-                        }
-                        if (mode == 4){
-                        cScore = cScore+1;
-                        }
-                        //uLCD.printf("Score: %d", Score);
-                        wait(1);
-                        if (mode == 1){
-                        answer = 1;
-                        }
-                            counter=counter+1;
-                        check = 1;
-                        }
+                    }
+                }
+            }
+             if (question == 10){
+                value = 0;
+                uLCD.cls();
+                uLCD.locate(1,2);
+                uLCD.printf("What is glass \nmainly made up \nof?\n\n\n");
+                uLCD.printf("1) Sand\n");
+                uLCD.printf("2) Crystals\n");
+                uLCD.printf("3) Highly \nCompressed \nWater\n");
+                while (check == 0){
+                    int value=mpr121.read(0x00);
+                    value +=mpr121.read(0x01)<<8;
                     if (value == 4){
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -726,49 +915,18 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
-                        answer = 0;
-                        }
-                        counter = counter+1;
-                        check = 1;
-                    }
-                }
-            }
-             if (question == 8){
-                value = 0;
-                uLCD.cls();
-                uLCD.locate(1,2);
-                 uLCD.printf("What is the \ncurrency of \nJapan?\n\n\n");
-                uLCD.printf("1) Pounds\n");
-                uLCD.printf("2) Yen\n");
-                uLCD.printf("3) Riki\n");
-                while (check == 0){
-                    int value=mpr121.read(0x00);
-                    value +=mpr121.read(0x01)<<8;
-                    if (value == 2){
-                        //play game over
-                        uLCD.cls();
-                        uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
-                        uLCD.display_image(0,0);
-                        FILE *wave_file;   
-                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
-                        waver.play(wave_file);
-                        fclose(wave_file);
-                        wait(1);
-                        uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter +1;
                         
                         check = 1;
                         }
-                    if (value == 4){
+                    if (value == 2){
                         //play correct image
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.set_sector_address(0x0000, 0x001D);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/right_taught.wav","r");
@@ -797,7 +955,38 @@
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter+1;
+                        check = 1;
+                    }
+                }
+            }
+            if (question == 11){
+                value = 0;
+                uLCD.cls();
+                uLCD.locate(1,2);
+                 uLCD.printf("In which city\n was the\n Titanic built?\n\n\n");
+                uLCD.printf("1) London\n");
+                uLCD.printf("2) Paris\n");
+                uLCD.printf("3) Belfast\n");
+                while (check == 0){
+                    int value=mpr121.read(0x00);
+                    value +=mpr121.read(0x01)<<8;
+                    if (value == 2){
+                        //play game over
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -805,7 +994,55 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter +1;
+                        
+                        check = 1;
+                        }
+                    if (value == 8){
+                        //play wrong
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/right_taught.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
                         if (mode == 1){
+                        nScore = nScore+1;
+                        }
+                        if (mode == 2){
+                        tScore = tScore+1;
+                        }
+                        if (mode == 4){
+                        cScore = cScore+1;
+                        }
+                        //uLCD.printf("Score: %d", Score);
+                        wait(1);
+                        if (mode == 1){
+                        answer = 1;
+                        }
+                            counter=counter+1;
+                        check = 1;
+                        }
+                    if (value == 4){
+                        //play correct
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter+1;
@@ -813,22 +1050,23 @@
                     }
                 }
             }
-             if (question == 9){
+
+             if (question == 12){
                 value = 0;
                 uLCD.cls();
                 uLCD.locate(1,2);
-                uLCD.printf("Who was Harry \nHoudini?\n\n\n");
-                uLCD.printf("1)An Escape Artist\n");
-                uLCD.printf("2)Fighter Pilot in WWII\n");
-                uLCD.printf("3) Harry Potter's Cousin\n");
+                 uLCD.printf("What animal has\nthe fastest \n metabolism?\n\n\n");
+                uLCD.printf("1) Cat\n");
+                uLCD.printf("2) Ostrich\n");
+                uLCD.printf("3) Hummingbird\n");
                 while (check == 0){
                     int value=mpr121.read(0x00);
                     value +=mpr121.read(0x01)<<8;
-                    if (value == 4){
+                    if (value == 2){
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -836,20 +1074,100 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter +1;
                         
                         check = 1;
                         }
-                    if (value == 2){
+                    if (value == 8){
+                        //play wrong image
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/right_taught.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 1){
+                        nScore = nScore+1;
+                        }
+                        if (mode == 2){
+                        tScore = tScore+1;
+                        }
+                        if (mode == 4){
+                        cScore = cScore+1;
+                        }
+                        //uLCD.printf("Score: %d", Score);
+                        wait(1);
+                        if (mode == 1){
+                        answer = 1;
+                        }
+                            counter=counter+1;
+                        check = 1;
+                        }
+                    if (value == 4){
                         //play correct image
                         uLCD.cls();
                         uLCD.media_init();
                         uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter+1;
+                        check = 1;
+                    }
+                }
+            }
+
+             if (question == 13){
+                value = 0;
+                uLCD.cls();
+                uLCD.locate(1,2);
+                 uLCD.printf("What is the\nlargest organ \nof the human\n body?\n\n\n");
+                uLCD.printf("1) Kidney\n");
+                uLCD.printf("2) Liver\n");
+                uLCD.printf("3) Brain\n");
+                while (check == 0){
+                    int value=mpr121.read(0x00);
+                    value +=mpr121.read(0x01)<<8;
+                    if (value == 2){
+                        //play game over
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter +1;
+                        
+                        check = 1;
+                        }
+                    if (value == 4){
+                        //play correct image
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/right_taught.wav","r");
                         waver.play(wave_file);
                         fclose(wave_file);
@@ -873,10 +1191,42 @@
                         check = 1;
                         }
                     if (value == 8){
+                        //play wrong image
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter+1;
+                        check = 1;
+                    }
+                }
+            }
+
+             if (question == 14){
+                value = 0;
+                uLCD.cls();
+                uLCD.locate(1,2);
+                 uLCD.printf("Who was the\nfirst U.S. \nPresident \nto live in the\n white house?\n\n\n");
+                uLCD.printf("1) George Washington\n");
+                uLCD.printf("2) Thomas Jefferson\n");
+                uLCD.printf("3) John Adams\n");
+                while (check == 0){
+                    int value=mpr121.read(0x00);
+                    value +=mpr121.read(0x01)<<8;
+                    if (value == 2){
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -884,7 +1234,55 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter +1;
+                        
+                        check = 1;
+                        }
+                    if (value == 8){
+                        //play wrong image
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/right_taught.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
                         if (mode == 1){
+                        nScore = nScore+1;
+                        }
+                        if (mode == 2){
+                        tScore = tScore+1;
+                        }
+                        if (mode == 4){
+                        cScore = cScore+1;
+                        }
+                        //uLCD.printf("Score: %d", Score);
+                        wait(1);
+                        if (mode == 1){
+                        answer = 1;
+                        }
+                            counter=counter+1;
+                        check = 1;
+                        }
+                    if (value == 4){
+                        //play correct
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter+1;
@@ -892,22 +1290,26 @@
                     }
                 }
             }
-             if (question == 10){
+
+
+
+
+             if (question == 15){
                 value = 0;
                 uLCD.cls();
                 uLCD.locate(1,2);
-                uLCD.printf("What is glass \nmainly made up \nof?\n\n\n");
-                uLCD.printf("1) Sand\n");
-                uLCD.printf("2) Crystals\n");
-                uLCD.printf("3) Highly \nCompressed \nWater\n");
+                 uLCD.printf("Who was the\noldest person to\n sign the\n Declaration\n of Independence?\n\n\n");
+                uLCD.printf("1) Thomas Jefferson\n");
+                uLCD.printf("2) George Washington\n");
+                uLCD.printf("3) Benjamin Franklin\n");
                 while (check == 0){
                     int value=mpr121.read(0x00);
                     value +=mpr121.read(0x01)<<8;
-                    if (value == 4){
+                    if (value == 2){
                         //play game over
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -915,7 +1317,87 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter +1;
+                        
+                        check = 1;
+                        }
+                    if (value == 8){
+                        //play wrong image
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/right_taught.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
                         if (mode == 1){
+                        nScore = nScore+1;
+                        }
+                        if (mode == 2){
+                        tScore = tScore+1;
+                        }
+                        if (mode == 4){
+                        cScore = cScore+1;
+                        }
+                        //uLCD.printf("Score: %d", Score);
+                        wait(1);
+                        if (mode == 1){
+                        answer = 1;
+                        }
+                            counter=counter+1;
+                        check = 1;
+                        }
+                    if (value == 4){
+                        //play correct
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
+                        answer = 0;
+                        }
+                        counter = counter+1;
+                        check = 1;
+                    }
+                }
+            }
+
+             if (question == 16){
+                value = 0;
+                uLCD.cls();
+                uLCD.locate(1,2);
+                 uLCD.printf("How many\n paintings\ndid Vincent Van\n Gogh sell? \n\n\n");
+                uLCD.printf("1) One\n");
+                uLCD.printf("2) Two\n");
+                uLCD.printf("3) Three\n");
+                while (check == 0){
+                    int value=mpr121.read(0x00);
+                    value +=mpr121.read(0x01)<<8;
+                    if (value == 4){
+                        //play correct image
+                        uLCD.cls();
+                        uLCD.media_init();
+                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.display_image(0,0);
+                        FILE *wave_file;   
+                        wave_file=fopen("/sd/sounds/wrong_last.wav","r");
+                        waver.play(wave_file);
+                        fclose(wave_file);
+                        wait(1);
+                        uLCD.cls();
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter +1;
@@ -923,10 +1405,10 @@
                         check = 1;
                         }
                     if (value == 2){
-                        //play correct image
+                        //play wrong image
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x005E);
+                        uLCD.set_sector_address(0x0000, 0x001D);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/right_taught.wav","r");
@@ -952,10 +1434,10 @@
                         check = 1;
                         }
                     if (value == 8){
-                        //play game over
+                        //play wrong image
                         uLCD.cls();
                         uLCD.media_init();
-                        uLCD.set_sector_address(0x0000, 0x001D);
+                        uLCD.set_sector_address(0x0000, 0x005E);
                         uLCD.display_image(0,0);
                         FILE *wave_file;   
                         wave_file=fopen("/sd/sounds/wrong_last.wav","r");
@@ -963,7 +1445,7 @@
                         fclose(wave_file);
                         wait(1);
                         uLCD.cls();
-                        if (mode == 1){
+                        if (mode == 4){
                         answer = 0;
                         }
                         counter = counter+1;