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