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
Exam/Exam.cpp@22:f8f36e88b2ca, 2019-04-28 (annotated)
- Committer:
- yfkwok
- Date:
- Sun Apr 28 18:58:10 2019 +0000
- Revision:
- 22:f8f36e88b2ca
- Parent:
- 13:02002658e718
- Child:
- 23:4a070960817a
28/04/2019 - Flag reset implementation, game parameters and difficulty adjustment
Who changed what in which revision?
User | Revision | Line number | New 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 | bool finished = false; |
yfkwok | 5:bc0691d02fd5 | 58 | |
yfkwok | 5:bc0691d02fd5 | 59 | while(pad.check_event(Gamepad::START_PRESSED) == false){ |
yfkwok | 5:bc0691d02fd5 | 60 | //music.gym(pad, !finished); |
yfkwok | 5:bc0691d02fd5 | 61 | switch (currentPage) { |
yfkwok | 5:bc0691d02fd5 | 62 | case PAGE_1: |
yfkwok | 5:bc0691d02fd5 | 63 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 64 | lcd.printString("Question 1",0,0); |
yfkwok | 5:bc0691d02fd5 | 65 | lcd.printString("What is the",0,1); |
yfkwok | 5:bc0691d02fd5 | 66 | lcd.printString("cut off",0,2); |
yfkwok | 5:bc0691d02fd5 | 67 | lcd.printString("frequency ",0,3); |
yfkwok | 5:bc0691d02fd5 | 68 | lcd.printString("of a circuit",0,4); |
yfkwok | 11:5a6b9dffd78a | 69 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 70 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 71 | if(pad.get_direction() == S){currentPage = PAGE_2; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 72 | if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();} |
yfkwok | 10:adff3c804985 | 73 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 74 | break; |
yfkwok | 5:bc0691d02fd5 | 75 | case PAGE_2: |
yfkwok | 5:bc0691d02fd5 | 76 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 77 | lcd.printString("formed by a",0,0); |
yfkwok | 5:bc0691d02fd5 | 78 | lcd.printString("50k resistor",0,1); |
yfkwok | 5:bc0691d02fd5 | 79 | lcd.printString("and capacitor",0,2); |
yfkwok | 5:bc0691d02fd5 | 80 | lcd.printString("of 120pF in",0,3); |
yfkwok | 5:bc0691d02fd5 | 81 | lcd.printString("series?",0,4); |
yfkwok | 11:5a6b9dffd78a | 82 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 83 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 84 | if(pad.get_direction() == S){currentPage = PAGE_3; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 85 | if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();} |
yfkwok | 10:adff3c804985 | 86 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 87 | break; |
yfkwok | 5:bc0691d02fd5 | 88 | case PAGE_3: |
yfkwok | 5:bc0691d02fd5 | 89 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 90 | if (point > 0){ |
yfkwok | 5:bc0691d02fd5 | 91 | lcd.printString("A. 26.5kHz",0,2); |
yfkwok | 5:bc0691d02fd5 | 92 | lcd.printString("B. 2.61MHz",0,3); |
yfkwok | 5:bc0691d02fd5 | 93 | lcd.printString("X. 26.3kHz",0,4); |
yfkwok | 5:bc0691d02fd5 | 94 | lcd.printString("Y. 26.5MHz",0,5); |
yfkwok | 5:bc0691d02fd5 | 95 | } |
yfkwok | 5:bc0691d02fd5 | 96 | else { |
yfkwok | 5:bc0691d02fd5 | 97 | lcd.printString("A. $%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 98 | lcd.printString("B. $%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 99 | lcd.printString("X. $%^&*",0,4); |
yfkwok | 5:bc0691d02fd5 | 100 | lcd.printString("Y. $%^&*",0,5); |
yfkwok | 5:bc0691d02fd5 | 101 | } |
yfkwok | 11:5a6b9dffd78a | 102 | lcd.drawSprite(39, 0, 4, 7, (int*)up); |
yfkwok | 5:bc0691d02fd5 | 103 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 104 | if(pad.get_direction() == N){currentPage = PAGE_2; pad.init_input();} |
yfkwok | 5:bc0691d02fd5 | 105 | if(pad.check_event(Gamepad::A_PRESSED) == true){ |
yfkwok | 5:bc0691d02fd5 | 106 | score++; |
yfkwok | 5:bc0691d02fd5 | 107 | currentPage = PAGE_4; |
yfkwok | 22:f8f36e88b2ca | 108 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 109 | } |
yfkwok | 5:bc0691d02fd5 | 110 | if((pad.check_event(Gamepad::B_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 111 | || (pad.check_event(Gamepad::X_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 112 | || (pad.check_event(Gamepad::Y_PRESSED) == true)){ |
yfkwok | 5:bc0691d02fd5 | 113 | currentPage = PAGE_4; |
yfkwok | 22:f8f36e88b2ca | 114 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 115 | } |
yfkwok | 10:adff3c804985 | 116 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 117 | break; |
yfkwok | 5:bc0691d02fd5 | 118 | case PAGE_4: |
yfkwok | 5:bc0691d02fd5 | 119 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 120 | lcd.printString("Question 2",0,0); |
yfkwok | 5:bc0691d02fd5 | 121 | lcd.printString("What is the",0,1); |
yfkwok | 5:bc0691d02fd5 | 122 | lcd.printString("integration",0,2); |
yfkwok | 5:bc0691d02fd5 | 123 | lcd.printString("of function",0,3); |
yfkwok | 5:bc0691d02fd5 | 124 | lcd.printString("1/(6+5cos(x))",0,4); |
yfkwok | 11:5a6b9dffd78a | 125 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 126 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 127 | if(pad.get_direction() == S){currentPage = PAGE_5; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 128 | if(pad.get_direction() == N){currentPage = PAGE_4; pad.init_input();} |
yfkwok | 10:adff3c804985 | 129 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 130 | break; |
yfkwok | 5:bc0691d02fd5 | 131 | case PAGE_5: |
yfkwok | 5:bc0691d02fd5 | 132 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 133 | lcd.printString("with respect",0,0); |
yfkwok | 5:bc0691d02fd5 | 134 | lcd.printString("to x for ",0,1); |
yfkwok | 5:bc0691d02fd5 | 135 | lcd.printString("[0,pi/2]?",0,2); |
yfkwok | 11:5a6b9dffd78a | 136 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 137 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 138 | if(pad.get_direction() == S){currentPage = PAGE_6; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 139 | if(pad.get_direction() == N){currentPage = PAGE_4; pad.init_input();} |
yfkwok | 10:adff3c804985 | 140 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 141 | break; |
yfkwok | 5:bc0691d02fd5 | 142 | case PAGE_6: |
yfkwok | 5:bc0691d02fd5 | 143 | lcd.clear(); |
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 | 5:bc0691d02fd5 | 197 | if(point > 2) { |
yfkwok | 5:bc0691d02fd5 | 198 | lcd.printString("A. -ln|cos(x)|",0,2); |
yfkwok | 5:bc0691d02fd5 | 199 | lcd.printString("B. -arctan(x)",0,3); |
yfkwok | 5:bc0691d02fd5 | 200 | lcd.printString("X. -ln|sec(x)|",0,4); |
yfkwok | 5:bc0691d02fd5 | 201 | lcd.printString("Y. -cot(1/x)",0,5); |
yfkwok | 5:bc0691d02fd5 | 202 | } |
yfkwok | 5:bc0691d02fd5 | 203 | else { |
yfkwok | 5:bc0691d02fd5 | 204 | lcd.printString("A. $%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 205 | lcd.printString("B. $%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 206 | lcd.printString("X. $%^&*",0,4); |
yfkwok | 5:bc0691d02fd5 | 207 | lcd.printString("Y. $%^&*",0,5); |
yfkwok | 5:bc0691d02fd5 | 208 | } |
yfkwok | 11:5a6b9dffd78a | 209 | lcd.drawSprite(39, 0, 4, 7, (int*)up); |
yfkwok | 5:bc0691d02fd5 | 210 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 211 | if(pad.get_direction() == N){currentPage = PAGE_8; pad.init_input();} |
yfkwok | 5:bc0691d02fd5 | 212 | if(pad.check_event(Gamepad::A_PRESSED) == true){ |
yfkwok | 5:bc0691d02fd5 | 213 | score++; |
yfkwok | 5:bc0691d02fd5 | 214 | currentPage = PAGE_10; |
yfkwok | 22:f8f36e88b2ca | 215 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 216 | } |
yfkwok | 5:bc0691d02fd5 | 217 | if((pad.check_event(Gamepad::B_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 218 | || (pad.check_event(Gamepad::Y_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 219 | || (pad.check_event(Gamepad::X_PRESSED) == true)){ |
yfkwok | 5:bc0691d02fd5 | 220 | currentPage = PAGE_10; |
yfkwok | 22:f8f36e88b2ca | 221 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 222 | } |
yfkwok | 10:adff3c804985 | 223 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 224 | break; |
yfkwok | 5:bc0691d02fd5 | 225 | case PAGE_10: |
yfkwok | 5:bc0691d02fd5 | 226 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 227 | lcd.printString("EXAM",0,0); |
yfkwok | 5:bc0691d02fd5 | 228 | lcd.printString("COMPLETE",0,1); |
yfkwok | 5:bc0691d02fd5 | 229 | lcd.printString("PRESS START",0,5); |
yfkwok | 5:bc0691d02fd5 | 230 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 231 | if(pad.check_event(Gamepad::START_PRESSED) == true) {finished = true; pad.init_input();} |
yfkwok | 10:adff3c804985 | 232 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 233 | break; |
yfkwok | 5:bc0691d02fd5 | 234 | } |
yfkwok | 5:bc0691d02fd5 | 235 | } |
yfkwok | 5:bc0691d02fd5 | 236 | return score; |
yfkwok | 5:bc0691d02fd5 | 237 | } |
yfkwok | 5:bc0691d02fd5 | 238 | |
yfkwok | 5:bc0691d02fd5 | 239 | int Exam::exam_q_two(Gamepad &pad, N5110 &lcd, int point) |
yfkwok | 5:bc0691d02fd5 | 240 | { |
yfkwok | 5:bc0691d02fd5 | 241 | pad.init(); |
yfkwok | 5:bc0691d02fd5 | 242 | Page currentPage = PAGE_1; |
yfkwok | 5:bc0691d02fd5 | 243 | int fps = 8.0; |
yfkwok | 5:bc0691d02fd5 | 244 | int score = 0; |
yfkwok | 11:5a6b9dffd78a | 245 | int down[4][7] = { |
yfkwok | 11:5a6b9dffd78a | 246 | {1,1,1,1,1,1,1}, |
yfkwok | 11:5a6b9dffd78a | 247 | {0,1,1,1,1,1,0}, |
yfkwok | 11:5a6b9dffd78a | 248 | {0,0,1,1,1,0,0}, |
yfkwok | 11:5a6b9dffd78a | 249 | {0,0,0,1,0,0,0}, |
yfkwok | 5:bc0691d02fd5 | 250 | }; |
yfkwok | 11:5a6b9dffd78a | 251 | int up[4][7] = { |
yfkwok | 11:5a6b9dffd78a | 252 | {0,0,0,1,0,0,0}, |
yfkwok | 11:5a6b9dffd78a | 253 | {0,0,1,1,1,0,0}, |
yfkwok | 11:5a6b9dffd78a | 254 | {0,1,1,1,1,1,0}, |
yfkwok | 11:5a6b9dffd78a | 255 | {1,1,1,1,1,1,1}, |
yfkwok | 5:bc0691d02fd5 | 256 | }; |
yfkwok | 5:bc0691d02fd5 | 257 | bool finished = false; |
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 | 5:bc0691d02fd5 | 279 | lcd.printString("photo that can",0,2); |
yfkwok | 5:bc0691d02fd5 | 280 | lcd.printString("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 | 5:bc0691d02fd5 | 290 | if (point > 0){ |
yfkwok | 5:bc0691d02fd5 | 291 | lcd.printString("A. 913.52nm",0,2); |
yfkwok | 5:bc0691d02fd5 | 292 | lcd.printString("B. 875.44nm",0,3); |
yfkwok | 5:bc0691d02fd5 | 293 | lcd.printString("X. 688.91nm",0,4); |
yfkwok | 5:bc0691d02fd5 | 294 | lcd.printString("Y. 31.29um",0,5); |
yfkwok | 5:bc0691d02fd5 | 295 | } |
yfkwok | 5:bc0691d02fd5 | 296 | else { |
yfkwok | 5:bc0691d02fd5 | 297 | lcd.printString("A. $%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 298 | lcd.printString("B. $%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 299 | lcd.printString("X. $%^&*",0,4); |
yfkwok | 5:bc0691d02fd5 | 300 | lcd.printString("Y. $%^&*",0,5); |
yfkwok | 5:bc0691d02fd5 | 301 | } |
yfkwok | 11:5a6b9dffd78a | 302 | lcd.drawSprite(39, 0, 4, 7, (int*)up); |
yfkwok | 5:bc0691d02fd5 | 303 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 304 | if(pad.get_direction() == N){currentPage = PAGE_2; pad.init_input();} |
yfkwok | 5:bc0691d02fd5 | 305 | if(pad.check_event(Gamepad::B_PRESSED) == true){ |
yfkwok | 5:bc0691d02fd5 | 306 | score++; |
yfkwok | 5:bc0691d02fd5 | 307 | currentPage = PAGE_4; |
yfkwok | 22:f8f36e88b2ca | 308 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 309 | } |
yfkwok | 5:bc0691d02fd5 | 310 | if((pad.check_event(Gamepad::A_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 311 | || (pad.check_event(Gamepad::X_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 312 | || (pad.check_event(Gamepad::Y_PRESSED) == true)){ |
yfkwok | 5:bc0691d02fd5 | 313 | currentPage = PAGE_4; |
yfkwok | 22:f8f36e88b2ca | 314 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 315 | } |
yfkwok | 10:adff3c804985 | 316 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 317 | break; |
yfkwok | 5:bc0691d02fd5 | 318 | case PAGE_4: |
yfkwok | 5:bc0691d02fd5 | 319 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 320 | lcd.printString("Question 2",0,0); |
yfkwok | 5:bc0691d02fd5 | 321 | lcd.printString("If the control",0,1); |
yfkwok | 5:bc0691d02fd5 | 322 | lcd.printString("signal for",0,2); |
yfkwok | 5:bc0691d02fd5 | 323 | lcd.printString("the switch is",0,3); |
yfkwok | 5:bc0691d02fd5 | 324 | lcd.printString("closed for",0,4); |
yfkwok | 11:5a6b9dffd78a | 325 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 326 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 327 | if(pad.get_direction() == S){currentPage = PAGE_5; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 328 | if(pad.get_direction() == N){currentPage = PAGE_4; pad.init_input();} |
yfkwok | 10:adff3c804985 | 329 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 330 | break; |
yfkwok | 5:bc0691d02fd5 | 331 | case PAGE_5: |
yfkwok | 5:bc0691d02fd5 | 332 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 333 | lcd.printString("t(on) = 70us",0,0); |
yfkwok | 5:bc0691d02fd5 | 334 | lcd.printString("t(off) = 30us",0,1); |
yfkwok | 5:bc0691d02fd5 | 335 | lcd.printString("what is the",0,2); |
yfkwok | 5:bc0691d02fd5 | 336 | lcd.printString("switching",0,3); |
yfkwok | 5:bc0691d02fd5 | 337 | lcd.printString("frequency?",0,4); |
yfkwok | 11:5a6b9dffd78a | 338 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 339 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 340 | if(pad.get_direction() == S){currentPage = PAGE_6; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 341 | if(pad.get_direction() == N){currentPage = PAGE_4; pad.init_input();} |
yfkwok | 10:adff3c804985 | 342 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 343 | break; |
yfkwok | 5:bc0691d02fd5 | 344 | case PAGE_6: |
yfkwok | 5:bc0691d02fd5 | 345 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 346 | if(point > 1) { |
yfkwok | 5:bc0691d02fd5 | 347 | lcd.printString("A. 10kHz",0,2); |
yfkwok | 5:bc0691d02fd5 | 348 | lcd.printString("B. 100kHz",0,3); |
yfkwok | 5:bc0691d02fd5 | 349 | lcd.printString("X. 1MHz",0,4); |
yfkwok | 5:bc0691d02fd5 | 350 | lcd.printString("Y. 10MHz",0,5); |
yfkwok | 5:bc0691d02fd5 | 351 | } |
yfkwok | 5:bc0691d02fd5 | 352 | else { |
yfkwok | 5:bc0691d02fd5 | 353 | lcd.printString("A. $%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 354 | lcd.printString("B. $%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 355 | lcd.printString("X. $%^&*",0,4); |
yfkwok | 5:bc0691d02fd5 | 356 | lcd.printString("Y. $%^&*",0,5); |
yfkwok | 5:bc0691d02fd5 | 357 | } |
yfkwok | 11:5a6b9dffd78a | 358 | lcd.drawSprite(39, 0, 4, 7, (int*)up); |
yfkwok | 5:bc0691d02fd5 | 359 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 360 | if(pad.get_direction() == N){currentPage = PAGE_5; pad.init_input();} |
yfkwok | 5:bc0691d02fd5 | 361 | if(pad.check_event(Gamepad::A_PRESSED) == true){ |
yfkwok | 5:bc0691d02fd5 | 362 | score++; |
yfkwok | 5:bc0691d02fd5 | 363 | currentPage = PAGE_7; |
yfkwok | 22:f8f36e88b2ca | 364 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 365 | } |
yfkwok | 5:bc0691d02fd5 | 366 | if((pad.check_event(Gamepad::Y_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 367 | || (pad.check_event(Gamepad::B_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 368 | || (pad.check_event(Gamepad::X_PRESSED) == true)){ |
yfkwok | 5:bc0691d02fd5 | 369 | currentPage = PAGE_7; |
yfkwok | 22:f8f36e88b2ca | 370 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 371 | } |
yfkwok | 10:adff3c804985 | 372 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 373 | break; |
yfkwok | 5:bc0691d02fd5 | 374 | case PAGE_7: |
yfkwok | 5:bc0691d02fd5 | 375 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 376 | lcd.printString("Question 3",0,0); |
yfkwok | 5:bc0691d02fd5 | 377 | lcd.printString("Let x(t) be a",0,1); |
yfkwok | 5:bc0691d02fd5 | 378 | lcd.printString("signal with",0,2); |
yfkwok | 5:bc0691d02fd5 | 379 | lcd.printString("x(t)=0 for t>2",0,3); |
yfkwok | 5:bc0691d02fd5 | 380 | lcd.printString("and t<6. What",0,4); |
yfkwok | 11:5a6b9dffd78a | 381 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 382 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 383 | if(pad.get_direction() == S){currentPage = PAGE_8; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 384 | if(pad.get_direction() == N){currentPage = PAGE_7; pad.init_input();} |
yfkwok | 10:adff3c804985 | 385 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 386 | break; |
yfkwok | 5:bc0691d02fd5 | 387 | case PAGE_8: |
yfkwok | 5:bc0691d02fd5 | 388 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 389 | lcd.printString("is the value",0,0); |
yfkwok | 5:bc0691d02fd5 | 390 | lcd.printString("of x(-t+5) at",0,1); |
yfkwok | 5:bc0691d02fd5 | 391 | lcd.printString("t=0?",0,2); |
yfkwok | 11:5a6b9dffd78a | 392 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 393 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 394 | if(pad.get_direction() == S){currentPage = PAGE_9; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 395 | if(pad.get_direction() == N){currentPage = PAGE_7; pad.init_input();} |
yfkwok | 10:adff3c804985 | 396 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 397 | break; |
yfkwok | 5:bc0691d02fd5 | 398 | case PAGE_9: |
yfkwok | 5:bc0691d02fd5 | 399 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 400 | if(point > 2) { |
yfkwok | 5:bc0691d02fd5 | 401 | lcd.printString("A. x(0)",0,2); |
yfkwok | 5:bc0691d02fd5 | 402 | lcd.printString("B. x(1)",0,3); |
yfkwok | 5:bc0691d02fd5 | 403 | lcd.printString("X. x(2)",0,4); |
yfkwok | 5:bc0691d02fd5 | 404 | lcd.printString("Y. x(3)",0,5); |
yfkwok | 5:bc0691d02fd5 | 405 | } |
yfkwok | 5:bc0691d02fd5 | 406 | else { |
yfkwok | 5:bc0691d02fd5 | 407 | lcd.printString("A. $%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 408 | lcd.printString("B. $%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 409 | lcd.printString("X. $%^&*",0,4); |
yfkwok | 5:bc0691d02fd5 | 410 | lcd.printString("Y. $%^&*",0,5); |
yfkwok | 5:bc0691d02fd5 | 411 | } |
yfkwok | 11:5a6b9dffd78a | 412 | lcd.drawSprite(39, 0, 4, 7, (int*)up); |
yfkwok | 5:bc0691d02fd5 | 413 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 414 | if(pad.get_direction() == N){currentPage = PAGE_8; pad.init_input();} |
yfkwok | 5:bc0691d02fd5 | 415 | if(pad.check_event(Gamepad::Y_PRESSED) == true){ |
yfkwok | 5:bc0691d02fd5 | 416 | score++; |
yfkwok | 5:bc0691d02fd5 | 417 | currentPage = PAGE_10; |
yfkwok | 22:f8f36e88b2ca | 418 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 419 | } |
yfkwok | 5:bc0691d02fd5 | 420 | if((pad.check_event(Gamepad::B_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 421 | || (pad.check_event(Gamepad::A_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 422 | || (pad.check_event(Gamepad::X_PRESSED) == true)){ |
yfkwok | 5:bc0691d02fd5 | 423 | currentPage = PAGE_10; |
yfkwok | 22:f8f36e88b2ca | 424 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 425 | } |
yfkwok | 10:adff3c804985 | 426 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 427 | break; |
yfkwok | 5:bc0691d02fd5 | 428 | case PAGE_10: |
yfkwok | 5:bc0691d02fd5 | 429 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 430 | lcd.printString("EXAM",0,0); |
yfkwok | 5:bc0691d02fd5 | 431 | lcd.printString("COMPLETE",0,1); |
yfkwok | 5:bc0691d02fd5 | 432 | lcd.printString("PRESS START",0,5); |
yfkwok | 5:bc0691d02fd5 | 433 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 434 | if(pad.check_event(Gamepad::START_PRESSED) == true) {finished = true; pad.init_input();} |
yfkwok | 10:adff3c804985 | 435 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 436 | break; |
yfkwok | 5:bc0691d02fd5 | 437 | } |
yfkwok | 5:bc0691d02fd5 | 438 | } |
yfkwok | 5:bc0691d02fd5 | 439 | return score; |
yfkwok | 5:bc0691d02fd5 | 440 | } |
yfkwok | 5:bc0691d02fd5 | 441 | |
yfkwok | 5:bc0691d02fd5 | 442 | int Exam::exam_q_three(Gamepad &pad, N5110 &lcd, int point) |
yfkwok | 5:bc0691d02fd5 | 443 | { |
yfkwok | 5:bc0691d02fd5 | 444 | pad.init(); |
yfkwok | 5:bc0691d02fd5 | 445 | Page currentPage = PAGE_1; |
yfkwok | 5:bc0691d02fd5 | 446 | int fps = 8.0; |
yfkwok | 5:bc0691d02fd5 | 447 | int score = 0; |
yfkwok | 11:5a6b9dffd78a | 448 | int down[4][7] = { |
yfkwok | 11:5a6b9dffd78a | 449 | {1,1,1,1,1,1,1}, |
yfkwok | 11:5a6b9dffd78a | 450 | {0,1,1,1,1,1,0}, |
yfkwok | 11:5a6b9dffd78a | 451 | {0,0,1,1,1,0,0}, |
yfkwok | 11:5a6b9dffd78a | 452 | {0,0,0,1,0,0,0}, |
yfkwok | 5:bc0691d02fd5 | 453 | }; |
yfkwok | 11:5a6b9dffd78a | 454 | int up[4][7] = { |
yfkwok | 11:5a6b9dffd78a | 455 | {0,0,0,1,0,0,0}, |
yfkwok | 11:5a6b9dffd78a | 456 | {0,0,1,1,1,0,0}, |
yfkwok | 11:5a6b9dffd78a | 457 | {0,1,1,1,1,1,0}, |
yfkwok | 11:5a6b9dffd78a | 458 | {1,1,1,1,1,1,1}, |
yfkwok | 5:bc0691d02fd5 | 459 | }; |
yfkwok | 5:bc0691d02fd5 | 460 | bool finished = false; |
yfkwok | 5:bc0691d02fd5 | 461 | |
yfkwok | 5:bc0691d02fd5 | 462 | while(pad.check_event(Gamepad::START_PRESSED) == false){ |
yfkwok | 5:bc0691d02fd5 | 463 | //music.gym(pad, !finished); |
yfkwok | 5:bc0691d02fd5 | 464 | switch (currentPage) { |
yfkwok | 5:bc0691d02fd5 | 465 | case PAGE_1: |
yfkwok | 5:bc0691d02fd5 | 466 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 467 | if (point > 0){ |
yfkwok | 5:bc0691d02fd5 | 468 | lcd.printString("Question 1",0,0); |
yfkwok | 5:bc0691d02fd5 | 469 | lcd.printString("The answer is",0,1); |
yfkwok | 5:bc0691d02fd5 | 470 | lcd.printString("A",0,2); |
yfkwok | 5:bc0691d02fd5 | 471 | } |
yfkwok | 5:bc0691d02fd5 | 472 | else { |
yfkwok | 5:bc0691d02fd5 | 473 | lcd.printString("$%^&*$%^&*",0,0); |
yfkwok | 5:bc0691d02fd5 | 474 | lcd.printString("$%^&*$%^&*",0,1); |
yfkwok | 5:bc0691d02fd5 | 475 | lcd.printString("$%^&*$%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 476 | lcd.printString("$%^&*$%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 477 | } |
yfkwok | 11:5a6b9dffd78a | 478 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 479 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 480 | if(pad.get_direction() == S){currentPage = PAGE_2; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 481 | if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();} |
yfkwok | 10:adff3c804985 | 482 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 483 | break; |
yfkwok | 5:bc0691d02fd5 | 484 | case PAGE_2: |
yfkwok | 5:bc0691d02fd5 | 485 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 486 | if (point > 0){ |
yfkwok | 5:bc0691d02fd5 | 487 | lcd.printString("A. ",0,2); |
yfkwok | 5:bc0691d02fd5 | 488 | lcd.printString("B. ",0,3); |
yfkwok | 5:bc0691d02fd5 | 489 | lcd.printString("X. ",0,4); |
yfkwok | 5:bc0691d02fd5 | 490 | lcd.printString("Y. ",0,5); |
yfkwok | 5:bc0691d02fd5 | 491 | } |
yfkwok | 5:bc0691d02fd5 | 492 | else { |
yfkwok | 5:bc0691d02fd5 | 493 | lcd.printString("A. $%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 494 | lcd.printString("B. $%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 495 | lcd.printString("X. $%^&*",0,4); |
yfkwok | 5:bc0691d02fd5 | 496 | lcd.printString("Y. $%^&*",0,5); |
yfkwok | 5:bc0691d02fd5 | 497 | } |
yfkwok | 11:5a6b9dffd78a | 498 | lcd.drawSprite(39, 0, 4, 7, (int*)up); |
yfkwok | 5:bc0691d02fd5 | 499 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 500 | if(pad.get_direction() == N){currentPage = PAGE_1; pad.init_input();} |
yfkwok | 5:bc0691d02fd5 | 501 | if(pad.check_event(Gamepad::A_PRESSED) == true){ |
yfkwok | 5:bc0691d02fd5 | 502 | score++; |
yfkwok | 5:bc0691d02fd5 | 503 | currentPage = PAGE_3; |
yfkwok | 22:f8f36e88b2ca | 504 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 505 | } |
yfkwok | 5:bc0691d02fd5 | 506 | if((pad.check_event(Gamepad::B_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 507 | || (pad.check_event(Gamepad::X_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 508 | || (pad.check_event(Gamepad::Y_PRESSED) == true)){ |
yfkwok | 5:bc0691d02fd5 | 509 | currentPage = PAGE_3; |
yfkwok | 22:f8f36e88b2ca | 510 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 511 | } |
yfkwok | 10:adff3c804985 | 512 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 513 | break; |
yfkwok | 5:bc0691d02fd5 | 514 | case PAGE_3: |
yfkwok | 5:bc0691d02fd5 | 515 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 516 | if (point > 1){ |
yfkwok | 5:bc0691d02fd5 | 517 | lcd.printString("Question 2",0,0); |
yfkwok | 5:bc0691d02fd5 | 518 | lcd.printString("The answer is",0,1); |
yfkwok | 5:bc0691d02fd5 | 519 | lcd.printString("B",0,2); |
yfkwok | 5:bc0691d02fd5 | 520 | } |
yfkwok | 5:bc0691d02fd5 | 521 | else { |
yfkwok | 5:bc0691d02fd5 | 522 | lcd.printString("$%^&*$%^&*",0,0); |
yfkwok | 5:bc0691d02fd5 | 523 | lcd.printString("$%^&*$%^&*",0,1); |
yfkwok | 5:bc0691d02fd5 | 524 | lcd.printString("$%^&*$%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 525 | lcd.printString("$%^&*$%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 526 | } |
yfkwok | 11:5a6b9dffd78a | 527 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 528 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 529 | if(pad.get_direction() == S){currentPage = PAGE_4; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 530 | if(pad.get_direction() == N){currentPage = PAGE_3; pad.init_input();} |
yfkwok | 10:adff3c804985 | 531 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 532 | break; |
yfkwok | 5:bc0691d02fd5 | 533 | case PAGE_4: |
yfkwok | 5:bc0691d02fd5 | 534 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 535 | if (point > 1){ |
yfkwok | 5:bc0691d02fd5 | 536 | lcd.printString("A. ",0,2); |
yfkwok | 5:bc0691d02fd5 | 537 | lcd.printString("B. ",0,3); |
yfkwok | 5:bc0691d02fd5 | 538 | lcd.printString("X. ",0,4); |
yfkwok | 5:bc0691d02fd5 | 539 | lcd.printString("Y. ",0,5); |
yfkwok | 5:bc0691d02fd5 | 540 | } |
yfkwok | 5:bc0691d02fd5 | 541 | else { |
yfkwok | 5:bc0691d02fd5 | 542 | lcd.printString("A. $%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 543 | lcd.printString("B. $%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 544 | lcd.printString("X. $%^&*",0,4); |
yfkwok | 5:bc0691d02fd5 | 545 | lcd.printString("Y. $%^&*",0,5); |
yfkwok | 5:bc0691d02fd5 | 546 | } |
yfkwok | 11:5a6b9dffd78a | 547 | lcd.drawSprite(39, 0, 4, 7, (int*)up); |
yfkwok | 5:bc0691d02fd5 | 548 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 549 | if(pad.get_direction() == N){currentPage = PAGE_3; pad.init_input();} |
yfkwok | 5:bc0691d02fd5 | 550 | if(pad.check_event(Gamepad::B_PRESSED) == true){ |
yfkwok | 5:bc0691d02fd5 | 551 | score++; |
yfkwok | 5:bc0691d02fd5 | 552 | currentPage = PAGE_5; |
yfkwok | 22:f8f36e88b2ca | 553 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 554 | } |
yfkwok | 5:bc0691d02fd5 | 555 | if((pad.check_event(Gamepad::A_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 556 | || (pad.check_event(Gamepad::X_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 557 | || (pad.check_event(Gamepad::Y_PRESSED) == true)){ |
yfkwok | 5:bc0691d02fd5 | 558 | currentPage = PAGE_5; |
yfkwok | 22:f8f36e88b2ca | 559 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 560 | } |
yfkwok | 10:adff3c804985 | 561 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 562 | break; |
yfkwok | 5:bc0691d02fd5 | 563 | case PAGE_5: |
yfkwok | 5:bc0691d02fd5 | 564 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 565 | if (point > 2){ |
yfkwok | 5:bc0691d02fd5 | 566 | lcd.printString("Question 3",0,0); |
yfkwok | 5:bc0691d02fd5 | 567 | lcd.printString("The answer is",0,1); |
yfkwok | 5:bc0691d02fd5 | 568 | lcd.printString("Y",0,2); |
yfkwok | 5:bc0691d02fd5 | 569 | } |
yfkwok | 5:bc0691d02fd5 | 570 | else { |
yfkwok | 5:bc0691d02fd5 | 571 | lcd.printString("$%^&*$%^&*",0,0); |
yfkwok | 5:bc0691d02fd5 | 572 | lcd.printString("$%^&*$%^&*",0,1); |
yfkwok | 5:bc0691d02fd5 | 573 | lcd.printString("$%^&*$%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 574 | lcd.printString("$%^&*$%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 575 | } |
yfkwok | 11:5a6b9dffd78a | 576 | lcd.drawSprite(39, 44, 4, 7, (int*)down); |
yfkwok | 5:bc0691d02fd5 | 577 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 578 | if(pad.get_direction() == S){currentPage = PAGE_6; pad.init_input();} |
yfkwok | 22:f8f36e88b2ca | 579 | if(pad.get_direction() == N){currentPage = PAGE_5; pad.init_input();} |
yfkwok | 10:adff3c804985 | 580 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 581 | break; |
yfkwok | 5:bc0691d02fd5 | 582 | case PAGE_6: |
yfkwok | 5:bc0691d02fd5 | 583 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 584 | if (point > 2){ |
yfkwok | 5:bc0691d02fd5 | 585 | lcd.printString("A. ",0,2); |
yfkwok | 5:bc0691d02fd5 | 586 | lcd.printString("B. ",0,3); |
yfkwok | 5:bc0691d02fd5 | 587 | lcd.printString("X. ",0,4); |
yfkwok | 5:bc0691d02fd5 | 588 | lcd.printString("Y. ",0,5); |
yfkwok | 5:bc0691d02fd5 | 589 | } |
yfkwok | 5:bc0691d02fd5 | 590 | else { |
yfkwok | 5:bc0691d02fd5 | 591 | lcd.printString("A. $%^&*",0,2); |
yfkwok | 5:bc0691d02fd5 | 592 | lcd.printString("B. $%^&*",0,3); |
yfkwok | 5:bc0691d02fd5 | 593 | lcd.printString("X. $%^&*",0,4); |
yfkwok | 5:bc0691d02fd5 | 594 | lcd.printString("Y. $%^&*",0,5); |
yfkwok | 5:bc0691d02fd5 | 595 | } |
yfkwok | 11:5a6b9dffd78a | 596 | lcd.drawSprite(39, 0, 4, 7, (int*)up); |
yfkwok | 5:bc0691d02fd5 | 597 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 598 | if(pad.get_direction() == N){currentPage = PAGE_5; pad.init_input();} |
yfkwok | 5:bc0691d02fd5 | 599 | if(pad.check_event(Gamepad::Y_PRESSED) == true){ |
yfkwok | 5:bc0691d02fd5 | 600 | score++; |
yfkwok | 5:bc0691d02fd5 | 601 | currentPage = PAGE_7; |
yfkwok | 22:f8f36e88b2ca | 602 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 603 | } |
yfkwok | 5:bc0691d02fd5 | 604 | if((pad.check_event(Gamepad::A_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 605 | || (pad.check_event(Gamepad::X_PRESSED) == true) |
yfkwok | 5:bc0691d02fd5 | 606 | || (pad.check_event(Gamepad::B_PRESSED) == true)){ |
yfkwok | 5:bc0691d02fd5 | 607 | currentPage = PAGE_7; |
yfkwok | 22:f8f36e88b2ca | 608 | pad.init_input(); |
yfkwok | 5:bc0691d02fd5 | 609 | } |
yfkwok | 10:adff3c804985 | 610 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 611 | break; |
yfkwok | 5:bc0691d02fd5 | 612 | case PAGE_7: |
yfkwok | 5:bc0691d02fd5 | 613 | lcd.clear(); |
yfkwok | 5:bc0691d02fd5 | 614 | lcd.printString("EXAM",0,0); |
yfkwok | 5:bc0691d02fd5 | 615 | lcd.printString("COMPLETE",0,1); |
yfkwok | 5:bc0691d02fd5 | 616 | lcd.printString("PRESS START",0,5); |
yfkwok | 5:bc0691d02fd5 | 617 | lcd.refresh(); |
yfkwok | 22:f8f36e88b2ca | 618 | if(pad.check_event(Gamepad::START_PRESSED) == true) {finished = true; pad.init_input();} |
yfkwok | 10:adff3c804985 | 619 | wait(1.0f/fps); |
yfkwok | 5:bc0691d02fd5 | 620 | break; |
yfkwok | 5:bc0691d02fd5 | 621 | } |
yfkwok | 5:bc0691d02fd5 | 622 | } |
yfkwok | 5:bc0691d02fd5 | 623 | return score; |
yfkwok | 5:bc0691d02fd5 | 624 | } |