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 03:03:46 2019 +0000
Revision:
31:0d2c19a285f6
Parent:
23:4a070960817a
Child:
33:f7ec806e14b6
08/05/2019 - Graduation music and animation added, game loops back to title screen after graduation. Game finished, need to added final documentation.

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