Game codes for Pokemon Academy Yiu Fai Kwok - 201198802 I have read the University Regulations on Plagiarism and state that the work covered by this declaration is my own and does not contain any unacknowledged work from other sources.

Dependencies:   mbed FXOS8700CQ mbed-rtos

Committer:
yfkwok
Date:
Wed May 08 23:57:04 2019 +0000
Revision:
33:f7ec806e14b6
Parent:
31:0d2c19a285f6
09/05/19 - Inline comment added, functionalities complete, all Deoxygen comment added for classes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yfkwok 5:bc0691d02fd5 1 #include "Exam.h"
yfkwok 5:bc0691d02fd5 2
yfkwok 5:bc0691d02fd5 3 Exam::Exam()
yfkwok 5:bc0691d02fd5 4 {
yfkwok 5:bc0691d02fd5 5
yfkwok 5:bc0691d02fd5 6 }
yfkwok 5:bc0691d02fd5 7
yfkwok 5:bc0691d02fd5 8 Exam::~Exam()
yfkwok 5:bc0691d02fd5 9 {
yfkwok 5:bc0691d02fd5 10
yfkwok 5:bc0691d02fd5 11 }
yfkwok 5:bc0691d02fd5 12
yfkwok 5:bc0691d02fd5 13 //Enumerate instruction menu from page 1 - 3
yfkwok 5:bc0691d02fd5 14 enum Page {
yfkwok 5:bc0691d02fd5 15 PAGE_1, PAGE_2, PAGE_3, PAGE_4, PAGE_5, PAGE_6, PAGE_7, PAGE_8, PAGE_9, PAGE_10
yfkwok 5:bc0691d02fd5 16 };
yfkwok 5:bc0691d02fd5 17
yfkwok 5:bc0691d02fd5 18 void Exam::exam_title(Gamepad &pad, N5110 &lcd)
yfkwok 5:bc0691d02fd5 19 {
yfkwok 5:bc0691d02fd5 20 lcd.clear();
yfkwok 11:5a6b9dffd78a 21 int instruct_data[10][78] = {
yfkwok 11:5a6b9dffd78a 22 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 23 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 24 {1,1,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,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 25 {1,1,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,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 26 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 27 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 28 {1,1,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,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 29 {1,1,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,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 30 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 31 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 5:bc0691d02fd5 32 };
yfkwok 11:5a6b9dffd78a 33 lcd.drawSprite(4, 20, 10, 78, (int*)instruct_data);
yfkwok 5:bc0691d02fd5 34 lcd.refresh();
yfkwok 5:bc0691d02fd5 35
yfkwok 5:bc0691d02fd5 36 music.exam_intro(pad);
yfkwok 5:bc0691d02fd5 37 }
yfkwok 5:bc0691d02fd5 38
yfkwok 5:bc0691d02fd5 39 int Exam::exam_q_one(Gamepad &pad, N5110 &lcd, int point)
yfkwok 5:bc0691d02fd5 40 {
yfkwok 5:bc0691d02fd5 41 pad.init();
yfkwok 5:bc0691d02fd5 42 Page currentPage = PAGE_1;
yfkwok 5:bc0691d02fd5 43 int fps = 8.0;
yfkwok 5:bc0691d02fd5 44 int score = 0;
yfkwok 11:5a6b9dffd78a 45 int down[4][7] = {
yfkwok 11:5a6b9dffd78a 46 {1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 47 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 48 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 49 {0,0,0,1,0,0,0},
yfkwok 5:bc0691d02fd5 50 };
yfkwok 11:5a6b9dffd78a 51 int up[4][7] = {
yfkwok 11:5a6b9dffd78a 52 {0,0,0,1,0,0,0},
yfkwok 11:5a6b9dffd78a 53 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 54 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 55 {1,1,1,1,1,1,1},
yfkwok 5:bc0691d02fd5 56 };
yfkwok 5:bc0691d02fd5 57
yfkwok 5:bc0691d02fd5 58 while(pad.check_event(Gamepad::START_PRESSED) == false){
yfkwok 5:bc0691d02fd5 59 switch (currentPage) {
yfkwok 5:bc0691d02fd5 60 case PAGE_1:
yfkwok 5:bc0691d02fd5 61 lcd.clear();
yfkwok 5:bc0691d02fd5 62 lcd.printString("Question 1",0,0);
yfkwok 5:bc0691d02fd5 63 lcd.printString("What is the",0,1);
yfkwok 5:bc0691d02fd5 64 lcd.printString("cut off",0,2);
yfkwok 5:bc0691d02fd5 65 lcd.printString("frequency ",0,3);
yfkwok 5:bc0691d02fd5 66 lcd.printString("of a circuit",0,4);
yfkwok 11:5a6b9dffd78a 67 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 68 lcd.refresh();
yfkwok 22:f8f36e88b2ca 69 if(pad.get_direction() == S){currentPage = PAGE_2; pad.init_input();}
yfkwok 22:f8f36e88b2ca 70 if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();}
yfkwok 10:adff3c804985 71 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 72 break;
yfkwok 5:bc0691d02fd5 73 case PAGE_2:
yfkwok 5:bc0691d02fd5 74 lcd.clear();
yfkwok 5:bc0691d02fd5 75 lcd.printString("formed by a",0,0);
yfkwok 5:bc0691d02fd5 76 lcd.printString("50k resistor",0,1);
yfkwok 5:bc0691d02fd5 77 lcd.printString("and capacitor",0,2);
yfkwok 5:bc0691d02fd5 78 lcd.printString("of 120pF in",0,3);
yfkwok 5:bc0691d02fd5 79 lcd.printString("series?",0,4);
yfkwok 11:5a6b9dffd78a 80 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 81 lcd.refresh();
yfkwok 22:f8f36e88b2ca 82 if(pad.get_direction() == S){currentPage = PAGE_3; pad.init_input();}
yfkwok 22:f8f36e88b2ca 83 if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();}
yfkwok 10:adff3c804985 84 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 85 break;
yfkwok 5:bc0691d02fd5 86 case PAGE_3:
yfkwok 5:bc0691d02fd5 87 lcd.clear();
yfkwok 33:f7ec806e14b6 88 // Disable answers when no mission is successful
yfkwok 5:bc0691d02fd5 89 if (point > 0){
yfkwok 5:bc0691d02fd5 90 lcd.printString("A. 26.5kHz",0,2);
yfkwok 5:bc0691d02fd5 91 lcd.printString("B. 2.61MHz",0,3);
yfkwok 5:bc0691d02fd5 92 lcd.printString("X. 26.3kHz",0,4);
yfkwok 5:bc0691d02fd5 93 lcd.printString("Y. 26.5MHz",0,5);
yfkwok 5:bc0691d02fd5 94 }
yfkwok 5:bc0691d02fd5 95 else {
yfkwok 5:bc0691d02fd5 96 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 97 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 98 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 99 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 100 }
yfkwok 11:5a6b9dffd78a 101 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 102 lcd.refresh();
yfkwok 22:f8f36e88b2ca 103 if(pad.get_direction() == N){currentPage = PAGE_2; pad.init_input();}
yfkwok 5:bc0691d02fd5 104 if(pad.check_event(Gamepad::A_PRESSED) == true){
yfkwok 5:bc0691d02fd5 105 score++;
yfkwok 5:bc0691d02fd5 106 currentPage = PAGE_4;
yfkwok 22:f8f36e88b2ca 107 pad.init_input();
yfkwok 5:bc0691d02fd5 108 }
yfkwok 5:bc0691d02fd5 109 if((pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 110 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 111 || (pad.check_event(Gamepad::Y_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 112 currentPage = PAGE_4;
yfkwok 22:f8f36e88b2ca 113 pad.init_input();
yfkwok 5:bc0691d02fd5 114 }
yfkwok 10:adff3c804985 115 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 116 break;
yfkwok 5:bc0691d02fd5 117 case PAGE_4:
yfkwok 5:bc0691d02fd5 118 lcd.clear();
yfkwok 5:bc0691d02fd5 119 lcd.printString("Question 2",0,0);
yfkwok 5:bc0691d02fd5 120 lcd.printString("What is the",0,1);
yfkwok 5:bc0691d02fd5 121 lcd.printString("integration",0,2);
yfkwok 5:bc0691d02fd5 122 lcd.printString("of function",0,3);
yfkwok 5:bc0691d02fd5 123 lcd.printString("1/(6+5cos(x))",0,4);
yfkwok 11:5a6b9dffd78a 124 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 125 lcd.refresh();
yfkwok 22:f8f36e88b2ca 126 if(pad.get_direction() == S){currentPage = PAGE_5; pad.init_input();}
yfkwok 22:f8f36e88b2ca 127 if(pad.get_direction() == N){currentPage = PAGE_4; pad.init_input();}
yfkwok 10:adff3c804985 128 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 129 break;
yfkwok 5:bc0691d02fd5 130 case PAGE_5:
yfkwok 5:bc0691d02fd5 131 lcd.clear();
yfkwok 5:bc0691d02fd5 132 lcd.printString("with respect",0,0);
yfkwok 5:bc0691d02fd5 133 lcd.printString("to x for ",0,1);
yfkwok 5:bc0691d02fd5 134 lcd.printString("[0,pi/2]?",0,2);
yfkwok 11:5a6b9dffd78a 135 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 136 lcd.refresh();
yfkwok 22:f8f36e88b2ca 137 if(pad.get_direction() == S){currentPage = PAGE_6; pad.init_input();}
yfkwok 22:f8f36e88b2ca 138 if(pad.get_direction() == N){currentPage = PAGE_4; pad.init_input();}
yfkwok 10:adff3c804985 139 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 140 break;
yfkwok 5:bc0691d02fd5 141 case PAGE_6:
yfkwok 5:bc0691d02fd5 142 lcd.clear();
yfkwok 33:f7ec806e14b6 143 // Disable answers when only 1 mission is successful
yfkwok 5:bc0691d02fd5 144 if(point > 1) {
yfkwok 5:bc0691d02fd5 145 lcd.printString("A. 0.1354",0,2);
yfkwok 5:bc0691d02fd5 146 lcd.printString("B. 2.617",0,3);
yfkwok 5:bc0691d02fd5 147 lcd.printString("X. 5.779",0,4);
yfkwok 5:bc0691d02fd5 148 lcd.printString("Y. 0.1766",0,5);
yfkwok 5:bc0691d02fd5 149 }
yfkwok 5:bc0691d02fd5 150 else {
yfkwok 5:bc0691d02fd5 151 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 152 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 153 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 154 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 155 }
yfkwok 11:5a6b9dffd78a 156 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 157 lcd.refresh();
yfkwok 22:f8f36e88b2ca 158 if(pad.get_direction() == N){currentPage = PAGE_5; pad.init_input();}
yfkwok 5:bc0691d02fd5 159 if(pad.check_event(Gamepad::Y_PRESSED) == true){
yfkwok 5:bc0691d02fd5 160 score++;
yfkwok 5:bc0691d02fd5 161 currentPage = PAGE_7;
yfkwok 22:f8f36e88b2ca 162 pad.init_input();
yfkwok 5:bc0691d02fd5 163 }
yfkwok 5:bc0691d02fd5 164 if((pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 165 || (pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 166 || (pad.check_event(Gamepad::X_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 167 currentPage = PAGE_7;
yfkwok 22:f8f36e88b2ca 168 pad.init_input();
yfkwok 5:bc0691d02fd5 169 }
yfkwok 10:adff3c804985 170 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 171 break;
yfkwok 5:bc0691d02fd5 172 case PAGE_7:
yfkwok 5:bc0691d02fd5 173 lcd.clear();
yfkwok 5:bc0691d02fd5 174 lcd.printString("Question 3",0,0);
yfkwok 5:bc0691d02fd5 175 lcd.printString("What is the",0,1);
yfkwok 5:bc0691d02fd5 176 lcd.printString("integration",0,2);
yfkwok 5:bc0691d02fd5 177 lcd.printString("of function",0,3);
yfkwok 5:bc0691d02fd5 178 lcd.printString("tan(x)",0,4);
yfkwok 11:5a6b9dffd78a 179 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 180 lcd.refresh();
yfkwok 22:f8f36e88b2ca 181 if(pad.get_direction() == S){currentPage = PAGE_8; pad.init_input();}
yfkwok 22:f8f36e88b2ca 182 if(pad.get_direction() == N){currentPage = PAGE_7; pad.init_input();}
yfkwok 10:adff3c804985 183 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 184 break;
yfkwok 5:bc0691d02fd5 185 case PAGE_8:
yfkwok 5:bc0691d02fd5 186 lcd.clear();
yfkwok 5:bc0691d02fd5 187 lcd.printString("with respect",0,0);
yfkwok 5:bc0691d02fd5 188 lcd.printString("to x?",0,1);
yfkwok 11:5a6b9dffd78a 189 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 190 lcd.refresh();
yfkwok 22:f8f36e88b2ca 191 if(pad.get_direction() == S){currentPage = PAGE_9; pad.init_input();}
yfkwok 22:f8f36e88b2ca 192 if(pad.get_direction() == N){currentPage = PAGE_7; pad.init_input();}
yfkwok 10:adff3c804985 193 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 194 break;
yfkwok 5:bc0691d02fd5 195 case PAGE_9:
yfkwok 10:adff3c804985 196 lcd.clear();
yfkwok 33:f7ec806e14b6 197 // Disable answers when only 2 missions are successful
yfkwok 5:bc0691d02fd5 198 if(point > 2) {
yfkwok 5:bc0691d02fd5 199 lcd.printString("A. -ln|cos(x)|",0,2);
yfkwok 5:bc0691d02fd5 200 lcd.printString("B. -arctan(x)",0,3);
yfkwok 5:bc0691d02fd5 201 lcd.printString("X. -ln|sec(x)|",0,4);
yfkwok 5:bc0691d02fd5 202 lcd.printString("Y. -cot(1/x)",0,5);
yfkwok 5:bc0691d02fd5 203 }
yfkwok 5:bc0691d02fd5 204 else {
yfkwok 5:bc0691d02fd5 205 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 206 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 207 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 208 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 209 }
yfkwok 11:5a6b9dffd78a 210 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 211 lcd.refresh();
yfkwok 22:f8f36e88b2ca 212 if(pad.get_direction() == N){currentPage = PAGE_8; pad.init_input();}
yfkwok 5:bc0691d02fd5 213 if(pad.check_event(Gamepad::A_PRESSED) == true){
yfkwok 5:bc0691d02fd5 214 score++;
yfkwok 5:bc0691d02fd5 215 currentPage = PAGE_10;
yfkwok 22:f8f36e88b2ca 216 pad.init_input();
yfkwok 5:bc0691d02fd5 217 }
yfkwok 5:bc0691d02fd5 218 if((pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 219 || (pad.check_event(Gamepad::Y_PRESSED) == true)
yfkwok 5:bc0691d02fd5 220 || (pad.check_event(Gamepad::X_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 221 currentPage = PAGE_10;
yfkwok 22:f8f36e88b2ca 222 pad.init_input();
yfkwok 5:bc0691d02fd5 223 }
yfkwok 10:adff3c804985 224 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 225 break;
yfkwok 5:bc0691d02fd5 226 case PAGE_10:
yfkwok 5:bc0691d02fd5 227 lcd.clear();
yfkwok 5:bc0691d02fd5 228 lcd.printString("EXAM",0,0);
yfkwok 5:bc0691d02fd5 229 lcd.printString("COMPLETE",0,1);
yfkwok 5:bc0691d02fd5 230 lcd.printString("PRESS START",0,5);
yfkwok 5:bc0691d02fd5 231 lcd.refresh();
yfkwok 23:4a070960817a 232 if(pad.check_event(Gamepad::START_PRESSED) == true) {pad.init_input();}
yfkwok 10:adff3c804985 233 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 234 break;
yfkwok 5:bc0691d02fd5 235 }
yfkwok 5:bc0691d02fd5 236 }
yfkwok 5:bc0691d02fd5 237 return score;
yfkwok 5:bc0691d02fd5 238 }
yfkwok 5:bc0691d02fd5 239
yfkwok 5:bc0691d02fd5 240 int Exam::exam_q_two(Gamepad &pad, N5110 &lcd, int point)
yfkwok 5:bc0691d02fd5 241 {
yfkwok 5:bc0691d02fd5 242 pad.init();
yfkwok 5:bc0691d02fd5 243 Page currentPage = PAGE_1;
yfkwok 5:bc0691d02fd5 244 int fps = 8.0;
yfkwok 5:bc0691d02fd5 245 int score = 0;
yfkwok 11:5a6b9dffd78a 246 int down[4][7] = {
yfkwok 11:5a6b9dffd78a 247 {1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 248 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 249 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 250 {0,0,0,1,0,0,0},
yfkwok 5:bc0691d02fd5 251 };
yfkwok 11:5a6b9dffd78a 252 int up[4][7] = {
yfkwok 11:5a6b9dffd78a 253 {0,0,0,1,0,0,0},
yfkwok 11:5a6b9dffd78a 254 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 255 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 256 {1,1,1,1,1,1,1},
yfkwok 5:bc0691d02fd5 257 };
yfkwok 5:bc0691d02fd5 258
yfkwok 5:bc0691d02fd5 259 while(pad.check_event(Gamepad::START_PRESSED) == false){
yfkwok 5:bc0691d02fd5 260 //music.gym(pad, !finished);
yfkwok 5:bc0691d02fd5 261 switch (currentPage) {
yfkwok 5:bc0691d02fd5 262 case PAGE_1:
yfkwok 5:bc0691d02fd5 263 lcd.clear();
yfkwok 5:bc0691d02fd5 264 lcd.printString("Question 1",0,0);
yfkwok 5:bc0691d02fd5 265 lcd.printString("A GaAs LED",0,1);
yfkwok 5:bc0691d02fd5 266 lcd.printString("with bandgap",0,2);
yfkwok 5:bc0691d02fd5 267 lcd.printString("of 1.42eV. ",0,3);
yfkwok 5:bc0691d02fd5 268 lcd.printString("Calculate",0,4);
yfkwok 11:5a6b9dffd78a 269 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 270 lcd.refresh();
yfkwok 22:f8f36e88b2ca 271 if(pad.get_direction() == S){currentPage = PAGE_2; pad.init_input();}
yfkwok 22:f8f36e88b2ca 272 if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();}
yfkwok 10:adff3c804985 273 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 274 break;
yfkwok 5:bc0691d02fd5 275 case PAGE_2:
yfkwok 5:bc0691d02fd5 276 lcd.clear();
yfkwok 5:bc0691d02fd5 277 lcd.printString("the longest",0,0);
yfkwok 5:bc0691d02fd5 278 lcd.printString("wavelength",0,1);
yfkwok 31:0d2c19a285f6 279 lcd.printString("photon that ",0,2);
yfkwok 31:0d2c19a285f6 280 lcd.printString("can be emitted",0,3);
yfkwok 5:bc0691d02fd5 281 lcd.printString("by it.",0,4);
yfkwok 11:5a6b9dffd78a 282 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 283 lcd.refresh();
yfkwok 22:f8f36e88b2ca 284 if(pad.get_direction() == S){currentPage = PAGE_3; pad.init_input();}
yfkwok 22:f8f36e88b2ca 285 if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();}
yfkwok 10:adff3c804985 286 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 287 break;
yfkwok 5:bc0691d02fd5 288 case PAGE_3:
yfkwok 5:bc0691d02fd5 289 lcd.clear();
yfkwok 33:f7ec806e14b6 290 // Disable answers when no mission is successful
yfkwok 5:bc0691d02fd5 291 if (point > 0){
yfkwok 5:bc0691d02fd5 292 lcd.printString("A. 913.52nm",0,2);
yfkwok 5:bc0691d02fd5 293 lcd.printString("B. 875.44nm",0,3);
yfkwok 5:bc0691d02fd5 294 lcd.printString("X. 688.91nm",0,4);
yfkwok 5:bc0691d02fd5 295 lcd.printString("Y. 31.29um",0,5);
yfkwok 5:bc0691d02fd5 296 }
yfkwok 5:bc0691d02fd5 297 else {
yfkwok 5:bc0691d02fd5 298 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 299 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 300 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 301 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 302 }
yfkwok 11:5a6b9dffd78a 303 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 304 lcd.refresh();
yfkwok 22:f8f36e88b2ca 305 if(pad.get_direction() == N){currentPage = PAGE_2; pad.init_input();}
yfkwok 5:bc0691d02fd5 306 if(pad.check_event(Gamepad::B_PRESSED) == true){
yfkwok 5:bc0691d02fd5 307 score++;
yfkwok 5:bc0691d02fd5 308 currentPage = PAGE_4;
yfkwok 22:f8f36e88b2ca 309 pad.init_input();
yfkwok 5:bc0691d02fd5 310 }
yfkwok 5:bc0691d02fd5 311 if((pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 312 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 313 || (pad.check_event(Gamepad::Y_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 314 currentPage = PAGE_4;
yfkwok 22:f8f36e88b2ca 315 pad.init_input();
yfkwok 5:bc0691d02fd5 316 }
yfkwok 10:adff3c804985 317 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 318 break;
yfkwok 5:bc0691d02fd5 319 case PAGE_4:
yfkwok 5:bc0691d02fd5 320 lcd.clear();
yfkwok 5:bc0691d02fd5 321 lcd.printString("Question 2",0,0);
yfkwok 5:bc0691d02fd5 322 lcd.printString("If the control",0,1);
yfkwok 5:bc0691d02fd5 323 lcd.printString("signal for",0,2);
yfkwok 5:bc0691d02fd5 324 lcd.printString("the switch is",0,3);
yfkwok 5:bc0691d02fd5 325 lcd.printString("closed for",0,4);
yfkwok 11:5a6b9dffd78a 326 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 327 lcd.refresh();
yfkwok 22:f8f36e88b2ca 328 if(pad.get_direction() == S){currentPage = PAGE_5; pad.init_input();}
yfkwok 22:f8f36e88b2ca 329 if(pad.get_direction() == N){currentPage = PAGE_4; pad.init_input();}
yfkwok 10:adff3c804985 330 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 331 break;
yfkwok 5:bc0691d02fd5 332 case PAGE_5:
yfkwok 5:bc0691d02fd5 333 lcd.clear();
yfkwok 5:bc0691d02fd5 334 lcd.printString("t(on) = 70us",0,0);
yfkwok 5:bc0691d02fd5 335 lcd.printString("t(off) = 30us",0,1);
yfkwok 5:bc0691d02fd5 336 lcd.printString("what is the",0,2);
yfkwok 5:bc0691d02fd5 337 lcd.printString("switching",0,3);
yfkwok 5:bc0691d02fd5 338 lcd.printString("frequency?",0,4);
yfkwok 11:5a6b9dffd78a 339 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 340 lcd.refresh();
yfkwok 22:f8f36e88b2ca 341 if(pad.get_direction() == S){currentPage = PAGE_6; pad.init_input();}
yfkwok 22:f8f36e88b2ca 342 if(pad.get_direction() == N){currentPage = PAGE_4; pad.init_input();}
yfkwok 10:adff3c804985 343 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 344 break;
yfkwok 5:bc0691d02fd5 345 case PAGE_6:
yfkwok 5:bc0691d02fd5 346 lcd.clear();
yfkwok 33:f7ec806e14b6 347 // Disable answers when only 1 mission is successful
yfkwok 5:bc0691d02fd5 348 if(point > 1) {
yfkwok 5:bc0691d02fd5 349 lcd.printString("A. 10kHz",0,2);
yfkwok 5:bc0691d02fd5 350 lcd.printString("B. 100kHz",0,3);
yfkwok 5:bc0691d02fd5 351 lcd.printString("X. 1MHz",0,4);
yfkwok 5:bc0691d02fd5 352 lcd.printString("Y. 10MHz",0,5);
yfkwok 5:bc0691d02fd5 353 }
yfkwok 5:bc0691d02fd5 354 else {
yfkwok 5:bc0691d02fd5 355 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 356 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 357 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 358 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 359 }
yfkwok 11:5a6b9dffd78a 360 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 361 lcd.refresh();
yfkwok 22:f8f36e88b2ca 362 if(pad.get_direction() == N){currentPage = PAGE_5; pad.init_input();}
yfkwok 5:bc0691d02fd5 363 if(pad.check_event(Gamepad::A_PRESSED) == true){
yfkwok 5:bc0691d02fd5 364 score++;
yfkwok 5:bc0691d02fd5 365 currentPage = PAGE_7;
yfkwok 22:f8f36e88b2ca 366 pad.init_input();
yfkwok 5:bc0691d02fd5 367 }
yfkwok 5:bc0691d02fd5 368 if((pad.check_event(Gamepad::Y_PRESSED) == true)
yfkwok 5:bc0691d02fd5 369 || (pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 370 || (pad.check_event(Gamepad::X_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 371 currentPage = PAGE_7;
yfkwok 22:f8f36e88b2ca 372 pad.init_input();
yfkwok 5:bc0691d02fd5 373 }
yfkwok 10:adff3c804985 374 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 375 break;
yfkwok 5:bc0691d02fd5 376 case PAGE_7:
yfkwok 5:bc0691d02fd5 377 lcd.clear();
yfkwok 5:bc0691d02fd5 378 lcd.printString("Question 3",0,0);
yfkwok 5:bc0691d02fd5 379 lcd.printString("Let x(t) be a",0,1);
yfkwok 5:bc0691d02fd5 380 lcd.printString("signal with",0,2);
yfkwok 5:bc0691d02fd5 381 lcd.printString("x(t)=0 for t>2",0,3);
yfkwok 5:bc0691d02fd5 382 lcd.printString("and t<6. What",0,4);
yfkwok 11:5a6b9dffd78a 383 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 384 lcd.refresh();
yfkwok 22:f8f36e88b2ca 385 if(pad.get_direction() == S){currentPage = PAGE_8; pad.init_input();}
yfkwok 22:f8f36e88b2ca 386 if(pad.get_direction() == N){currentPage = PAGE_7; pad.init_input();}
yfkwok 10:adff3c804985 387 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 388 break;
yfkwok 5:bc0691d02fd5 389 case PAGE_8:
yfkwok 5:bc0691d02fd5 390 lcd.clear();
yfkwok 5:bc0691d02fd5 391 lcd.printString("is the value",0,0);
yfkwok 5:bc0691d02fd5 392 lcd.printString("of x(-t+5) at",0,1);
yfkwok 5:bc0691d02fd5 393 lcd.printString("t=0?",0,2);
yfkwok 11:5a6b9dffd78a 394 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 395 lcd.refresh();
yfkwok 22:f8f36e88b2ca 396 if(pad.get_direction() == S){currentPage = PAGE_9; pad.init_input();}
yfkwok 22:f8f36e88b2ca 397 if(pad.get_direction() == N){currentPage = PAGE_7; pad.init_input();}
yfkwok 10:adff3c804985 398 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 399 break;
yfkwok 5:bc0691d02fd5 400 case PAGE_9:
yfkwok 5:bc0691d02fd5 401 lcd.clear();
yfkwok 33:f7ec806e14b6 402 // Disable answers when only 2 missions are successful
yfkwok 5:bc0691d02fd5 403 if(point > 2) {
yfkwok 5:bc0691d02fd5 404 lcd.printString("A. x(0)",0,2);
yfkwok 5:bc0691d02fd5 405 lcd.printString("B. x(1)",0,3);
yfkwok 5:bc0691d02fd5 406 lcd.printString("X. x(2)",0,4);
yfkwok 5:bc0691d02fd5 407 lcd.printString("Y. x(3)",0,5);
yfkwok 5:bc0691d02fd5 408 }
yfkwok 5:bc0691d02fd5 409 else {
yfkwok 5:bc0691d02fd5 410 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 411 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 412 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 413 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 414 }
yfkwok 11:5a6b9dffd78a 415 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 416 lcd.refresh();
yfkwok 22:f8f36e88b2ca 417 if(pad.get_direction() == N){currentPage = PAGE_8; pad.init_input();}
yfkwok 5:bc0691d02fd5 418 if(pad.check_event(Gamepad::Y_PRESSED) == true){
yfkwok 5:bc0691d02fd5 419 score++;
yfkwok 5:bc0691d02fd5 420 currentPage = PAGE_10;
yfkwok 22:f8f36e88b2ca 421 pad.init_input();
yfkwok 5:bc0691d02fd5 422 }
yfkwok 5:bc0691d02fd5 423 if((pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 424 || (pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 425 || (pad.check_event(Gamepad::X_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 426 currentPage = PAGE_10;
yfkwok 22:f8f36e88b2ca 427 pad.init_input();
yfkwok 5:bc0691d02fd5 428 }
yfkwok 10:adff3c804985 429 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 430 break;
yfkwok 5:bc0691d02fd5 431 case PAGE_10:
yfkwok 5:bc0691d02fd5 432 lcd.clear();
yfkwok 5:bc0691d02fd5 433 lcd.printString("EXAM",0,0);
yfkwok 5:bc0691d02fd5 434 lcd.printString("COMPLETE",0,1);
yfkwok 5:bc0691d02fd5 435 lcd.printString("PRESS START",0,5);
yfkwok 5:bc0691d02fd5 436 lcd.refresh();
yfkwok 23:4a070960817a 437 if(pad.check_event(Gamepad::START_PRESSED) == true) {pad.init_input();}
yfkwok 10:adff3c804985 438 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 439 break;
yfkwok 5:bc0691d02fd5 440 }
yfkwok 5:bc0691d02fd5 441 }
yfkwok 5:bc0691d02fd5 442 return score;
yfkwok 5:bc0691d02fd5 443 }
yfkwok 5:bc0691d02fd5 444
yfkwok 5:bc0691d02fd5 445 int Exam::exam_q_three(Gamepad &pad, N5110 &lcd, int point)
yfkwok 5:bc0691d02fd5 446 {
yfkwok 5:bc0691d02fd5 447 pad.init();
yfkwok 5:bc0691d02fd5 448 Page currentPage = PAGE_1;
yfkwok 5:bc0691d02fd5 449 int fps = 8.0;
yfkwok 5:bc0691d02fd5 450 int score = 0;
yfkwok 11:5a6b9dffd78a 451 int down[4][7] = {
yfkwok 11:5a6b9dffd78a 452 {1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 453 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 454 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 455 {0,0,0,1,0,0,0},
yfkwok 5:bc0691d02fd5 456 };
yfkwok 11:5a6b9dffd78a 457 int up[4][7] = {
yfkwok 11:5a6b9dffd78a 458 {0,0,0,1,0,0,0},
yfkwok 11:5a6b9dffd78a 459 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 460 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 461 {1,1,1,1,1,1,1},
yfkwok 5:bc0691d02fd5 462 };
yfkwok 5:bc0691d02fd5 463
yfkwok 5:bc0691d02fd5 464 while(pad.check_event(Gamepad::START_PRESSED) == false){
yfkwok 5:bc0691d02fd5 465 //music.gym(pad, !finished);
yfkwok 5:bc0691d02fd5 466 switch (currentPage) {
yfkwok 5:bc0691d02fd5 467 case PAGE_1:
yfkwok 5:bc0691d02fd5 468 lcd.clear();
yfkwok 33:f7ec806e14b6 469 // Disable answers and questions when no mission is successful
yfkwok 5:bc0691d02fd5 470 if (point > 0){
yfkwok 5:bc0691d02fd5 471 lcd.printString("Question 1",0,0);
yfkwok 5:bc0691d02fd5 472 lcd.printString("The answer is",0,1);
yfkwok 5:bc0691d02fd5 473 lcd.printString("A",0,2);
yfkwok 5:bc0691d02fd5 474 }
yfkwok 5:bc0691d02fd5 475 else {
yfkwok 5:bc0691d02fd5 476 lcd.printString("$%^&*$%^&*",0,0);
yfkwok 5:bc0691d02fd5 477 lcd.printString("$%^&*$%^&*",0,1);
yfkwok 5:bc0691d02fd5 478 lcd.printString("$%^&*$%^&*",0,2);
yfkwok 5:bc0691d02fd5 479 lcd.printString("$%^&*$%^&*",0,3);
yfkwok 5:bc0691d02fd5 480 }
yfkwok 11:5a6b9dffd78a 481 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 482 lcd.refresh();
yfkwok 22:f8f36e88b2ca 483 if(pad.get_direction() == S){currentPage = PAGE_2; pad.init_input();}
yfkwok 22:f8f36e88b2ca 484 if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();}
yfkwok 10:adff3c804985 485 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 486 break;
yfkwok 5:bc0691d02fd5 487 case PAGE_2:
yfkwok 5:bc0691d02fd5 488 lcd.clear();
yfkwok 5:bc0691d02fd5 489 if (point > 0){
yfkwok 5:bc0691d02fd5 490 lcd.printString("A. ",0,2);
yfkwok 5:bc0691d02fd5 491 lcd.printString("B. ",0,3);
yfkwok 5:bc0691d02fd5 492 lcd.printString("X. ",0,4);
yfkwok 5:bc0691d02fd5 493 lcd.printString("Y. ",0,5);
yfkwok 5:bc0691d02fd5 494 }
yfkwok 5:bc0691d02fd5 495 else {
yfkwok 5:bc0691d02fd5 496 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 497 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 498 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 499 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 500 }
yfkwok 11:5a6b9dffd78a 501 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 502 lcd.refresh();
yfkwok 22:f8f36e88b2ca 503 if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();}
yfkwok 5:bc0691d02fd5 504 if(pad.check_event(Gamepad::A_PRESSED) == true){
yfkwok 5:bc0691d02fd5 505 score++;
yfkwok 5:bc0691d02fd5 506 currentPage = PAGE_3;
yfkwok 22:f8f36e88b2ca 507 pad.init_input();
yfkwok 5:bc0691d02fd5 508 }
yfkwok 5:bc0691d02fd5 509 if((pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 510 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 511 || (pad.check_event(Gamepad::Y_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 512 currentPage = PAGE_3;
yfkwok 22:f8f36e88b2ca 513 pad.init_input();
yfkwok 5:bc0691d02fd5 514 }
yfkwok 10:adff3c804985 515 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 516 break;
yfkwok 5:bc0691d02fd5 517 case PAGE_3:
yfkwok 5:bc0691d02fd5 518 lcd.clear();
yfkwok 33:f7ec806e14b6 519 // Disable answers and questions when only 1 mission is successful
yfkwok 5:bc0691d02fd5 520 if (point > 1){
yfkwok 5:bc0691d02fd5 521 lcd.printString("Question 2",0,0);
yfkwok 5:bc0691d02fd5 522 lcd.printString("The answer is",0,1);
yfkwok 5:bc0691d02fd5 523 lcd.printString("B",0,2);
yfkwok 5:bc0691d02fd5 524 }
yfkwok 5:bc0691d02fd5 525 else {
yfkwok 5:bc0691d02fd5 526 lcd.printString("$%^&*$%^&*",0,0);
yfkwok 5:bc0691d02fd5 527 lcd.printString("$%^&*$%^&*",0,1);
yfkwok 5:bc0691d02fd5 528 lcd.printString("$%^&*$%^&*",0,2);
yfkwok 5:bc0691d02fd5 529 lcd.printString("$%^&*$%^&*",0,3);
yfkwok 5:bc0691d02fd5 530 }
yfkwok 11:5a6b9dffd78a 531 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 532 lcd.refresh();
yfkwok 22:f8f36e88b2ca 533 if(pad.get_direction() == S){currentPage = PAGE_4; pad.init_input();}
yfkwok 22:f8f36e88b2ca 534 if(pad.get_direction() == N){currentPage = PAGE_3; pad.init_input();}
yfkwok 10:adff3c804985 535 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 536 break;
yfkwok 5:bc0691d02fd5 537 case PAGE_4:
yfkwok 5:bc0691d02fd5 538 lcd.clear();
yfkwok 33:f7ec806e14b6 539 // Disable answers and questions when only 2 missions are successful
yfkwok 5:bc0691d02fd5 540 if (point > 1){
yfkwok 5:bc0691d02fd5 541 lcd.printString("A. ",0,2);
yfkwok 5:bc0691d02fd5 542 lcd.printString("B. ",0,3);
yfkwok 5:bc0691d02fd5 543 lcd.printString("X. ",0,4);
yfkwok 5:bc0691d02fd5 544 lcd.printString("Y. ",0,5);
yfkwok 5:bc0691d02fd5 545 }
yfkwok 5:bc0691d02fd5 546 else {
yfkwok 5:bc0691d02fd5 547 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 548 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 549 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 550 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 551 }
yfkwok 11:5a6b9dffd78a 552 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 553 lcd.refresh();
yfkwok 22:f8f36e88b2ca 554 if(pad.get_direction() == N){currentPage = PAGE_3; pad.init_input();}
yfkwok 5:bc0691d02fd5 555 if(pad.check_event(Gamepad::B_PRESSED) == true){
yfkwok 5:bc0691d02fd5 556 score++;
yfkwok 5:bc0691d02fd5 557 currentPage = PAGE_5;
yfkwok 22:f8f36e88b2ca 558 pad.init_input();
yfkwok 5:bc0691d02fd5 559 }
yfkwok 5:bc0691d02fd5 560 if((pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 561 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 562 || (pad.check_event(Gamepad::Y_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 563 currentPage = PAGE_5;
yfkwok 22:f8f36e88b2ca 564 pad.init_input();
yfkwok 5:bc0691d02fd5 565 }
yfkwok 10:adff3c804985 566 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 567 break;
yfkwok 5:bc0691d02fd5 568 case PAGE_5:
yfkwok 5:bc0691d02fd5 569 lcd.clear();
yfkwok 5:bc0691d02fd5 570 if (point > 2){
yfkwok 5:bc0691d02fd5 571 lcd.printString("Question 3",0,0);
yfkwok 5:bc0691d02fd5 572 lcd.printString("The answer is",0,1);
yfkwok 5:bc0691d02fd5 573 lcd.printString("Y",0,2);
yfkwok 5:bc0691d02fd5 574 }
yfkwok 5:bc0691d02fd5 575 else {
yfkwok 5:bc0691d02fd5 576 lcd.printString("$%^&*$%^&*",0,0);
yfkwok 5:bc0691d02fd5 577 lcd.printString("$%^&*$%^&*",0,1);
yfkwok 5:bc0691d02fd5 578 lcd.printString("$%^&*$%^&*",0,2);
yfkwok 5:bc0691d02fd5 579 lcd.printString("$%^&*$%^&*",0,3);
yfkwok 5:bc0691d02fd5 580 }
yfkwok 11:5a6b9dffd78a 581 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 582 lcd.refresh();
yfkwok 22:f8f36e88b2ca 583 if(pad.get_direction() == S){currentPage = PAGE_6; pad.init_input();}
yfkwok 22:f8f36e88b2ca 584 if(pad.get_direction() == N){currentPage = PAGE_5; pad.init_input();}
yfkwok 10:adff3c804985 585 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 586 break;
yfkwok 5:bc0691d02fd5 587 case PAGE_6:
yfkwok 5:bc0691d02fd5 588 lcd.clear();
yfkwok 5:bc0691d02fd5 589 if (point > 2){
yfkwok 5:bc0691d02fd5 590 lcd.printString("A. ",0,2);
yfkwok 5:bc0691d02fd5 591 lcd.printString("B. ",0,3);
yfkwok 5:bc0691d02fd5 592 lcd.printString("X. ",0,4);
yfkwok 5:bc0691d02fd5 593 lcd.printString("Y. ",0,5);
yfkwok 5:bc0691d02fd5 594 }
yfkwok 5:bc0691d02fd5 595 else {
yfkwok 5:bc0691d02fd5 596 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 597 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 598 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 599 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 600 }
yfkwok 11:5a6b9dffd78a 601 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 602 lcd.refresh();
yfkwok 22:f8f36e88b2ca 603 if(pad.get_direction() == N){currentPage = PAGE_5; pad.init_input();}
yfkwok 5:bc0691d02fd5 604 if(pad.check_event(Gamepad::Y_PRESSED) == true){
yfkwok 5:bc0691d02fd5 605 score++;
yfkwok 5:bc0691d02fd5 606 currentPage = PAGE_7;
yfkwok 22:f8f36e88b2ca 607 pad.init_input();
yfkwok 5:bc0691d02fd5 608 }
yfkwok 5:bc0691d02fd5 609 if((pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 610 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 611 || (pad.check_event(Gamepad::B_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 612 currentPage = PAGE_7;
yfkwok 22:f8f36e88b2ca 613 pad.init_input();
yfkwok 5:bc0691d02fd5 614 }
yfkwok 10:adff3c804985 615 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 616 break;
yfkwok 5:bc0691d02fd5 617 case PAGE_7:
yfkwok 5:bc0691d02fd5 618 lcd.clear();
yfkwok 5:bc0691d02fd5 619 lcd.printString("EXAM",0,0);
yfkwok 5:bc0691d02fd5 620 lcd.printString("COMPLETE",0,1);
yfkwok 5:bc0691d02fd5 621 lcd.printString("PRESS START",0,5);
yfkwok 5:bc0691d02fd5 622 lcd.refresh();
yfkwok 23:4a070960817a 623 if(pad.check_event(Gamepad::START_PRESSED) == true) {pad.init_input();}
yfkwok 10:adff3c804985 624 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 625 break;
yfkwok 5:bc0691d02fd5 626 }
yfkwok 5:bc0691d02fd5 627 }
yfkwok 5:bc0691d02fd5 628 return score;
yfkwok 5:bc0691d02fd5 629 }