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
Diff: Exam/Exam.cpp
- Revision:
- 11:5a6b9dffd78a
- Parent:
- 10:adff3c804985
- Child:
- 13:02002658e718
--- a/Exam/Exam.cpp Fri Apr 12 17:19:14 2019 +0000 +++ b/Exam/Exam.cpp Sun Apr 14 15:56:58 2019 +0000 @@ -18,19 +18,19 @@ void Exam::exam_title(Gamepad &pad, N5110 &lcd) { lcd.clear(); - static int instruct_data[] = { - 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, - 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, - 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, - 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, - 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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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}, + {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}, + {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}, }; - lcd.drawSprite(4, 20, 10, 78, instruct_data); + lcd.drawSprite(4, 20, 10, 78, (int*)instruct_data); lcd.refresh(); music.exam_intro(pad); @@ -42,17 +42,17 @@ Page currentPage = PAGE_1; int fps = 8.0; int score = 0; - static int down[] = { - 1,1,1,1,1,1,1, - 0,1,1,1,1,1,0, - 0,0,1,1,1,0,0, - 0,0,0,1,0,0,0 + int down[4][7] = { + {1,1,1,1,1,1,1}, + {0,1,1,1,1,1,0}, + {0,0,1,1,1,0,0}, + {0,0,0,1,0,0,0}, }; - static int up[] = { - 0,0,0,1,0,0,0, - 0,0,1,1,1,0,0, - 0,1,1,1,1,1,0, - 1,1,1,1,1,1,1 + int up[4][7] = { + {0,0,0,1,0,0,0}, + {0,0,1,1,1,0,0}, + {0,1,1,1,1,1,0}, + {1,1,1,1,1,1,1}, }; bool finished = false; @@ -66,7 +66,7 @@ lcd.printString("cut off",0,2); lcd.printString("frequency ",0,3); lcd.printString("of a circuit",0,4); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_2;} if(pad.get_direction() == N){currentPage = PAGE_1;} @@ -79,7 +79,7 @@ lcd.printString("and capacitor",0,2); lcd.printString("of 120pF in",0,3); lcd.printString("series?",0,4); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_3;} if(pad.get_direction() == N){currentPage = PAGE_1;} @@ -99,7 +99,7 @@ lcd.printString("X. $%^&*",0,4); lcd.printString("Y. $%^&*",0,5); } - lcd.drawSprite(39, 0, 4, 7, up); + lcd.drawSprite(39, 0, 4, 7, (int*)up); lcd.refresh(); if(pad.get_direction() == N){currentPage = PAGE_2;} if(pad.check_event(Gamepad::A_PRESSED) == true){ @@ -120,7 +120,7 @@ lcd.printString("integration",0,2); lcd.printString("of function",0,3); lcd.printString("1/(6+5cos(x))",0,4); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_5;} if(pad.get_direction() == N){currentPage = PAGE_4;} @@ -131,7 +131,7 @@ lcd.printString("with respect",0,0); lcd.printString("to x for ",0,1); lcd.printString("[0,pi/2]?",0,2); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_6;} if(pad.get_direction() == N){currentPage = PAGE_4;} @@ -151,7 +151,7 @@ lcd.printString("X. $%^&*",0,4); lcd.printString("Y. $%^&*",0,5); } - lcd.drawSprite(39, 0, 4, 7, up); + lcd.drawSprite(39, 0, 4, 7, (int*)up); lcd.refresh(); if(pad.get_direction() == N){currentPage = PAGE_5;} if(pad.check_event(Gamepad::Y_PRESSED) == true){ @@ -172,7 +172,7 @@ lcd.printString("integration",0,2); lcd.printString("of function",0,3); lcd.printString("tan(x)",0,4); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_8;} if(pad.get_direction() == N){currentPage = PAGE_7;} @@ -182,7 +182,7 @@ lcd.clear(); lcd.printString("with respect",0,0); lcd.printString("to x?",0,1); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_9;} if(pad.get_direction() == N){currentPage = PAGE_7;} @@ -202,7 +202,7 @@ lcd.printString("X. $%^&*",0,4); lcd.printString("Y. $%^&*",0,5); } - lcd.drawSprite(39, 0, 4, 7, up); + lcd.drawSprite(39, 0, 4, 7, (int*)up); lcd.refresh(); if(pad.get_direction() == N){currentPage = PAGE_8;} if(pad.check_event(Gamepad::A_PRESSED) == true){ @@ -236,17 +236,17 @@ Page currentPage = PAGE_1; int fps = 8.0; int score = 0; - static int down[] = { - 1,1,1,1,1,1,1, - 0,1,1,1,1,1,0, - 0,0,1,1,1,0,0, - 0,0,0,1,0,0,0 + int down[4][7] = { + {1,1,1,1,1,1,1}, + {0,1,1,1,1,1,0}, + {0,0,1,1,1,0,0}, + {0,0,0,1,0,0,0}, }; - static int up[] = { - 0,0,0,1,0,0,0, - 0,0,1,1,1,0,0, - 0,1,1,1,1,1,0, - 1,1,1,1,1,1,1 + int up[4][7] = { + {0,0,0,1,0,0,0}, + {0,0,1,1,1,0,0}, + {0,1,1,1,1,1,0}, + {1,1,1,1,1,1,1}, }; bool finished = false; @@ -260,7 +260,7 @@ lcd.printString("with bandgap",0,2); lcd.printString("of 1.42eV. ",0,3); lcd.printString("Calculate",0,4); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_2;} if(pad.get_direction() == N){currentPage = PAGE_1;} @@ -273,7 +273,7 @@ lcd.printString("photo that can",0,2); lcd.printString("be emitted",0,3); lcd.printString("by it.",0,4); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_3;} if(pad.get_direction() == N){currentPage = PAGE_1;} @@ -293,7 +293,7 @@ lcd.printString("X. $%^&*",0,4); lcd.printString("Y. $%^&*",0,5); } - lcd.drawSprite(39, 0, 4, 7, up); + lcd.drawSprite(39, 0, 4, 7, (int*)up); lcd.refresh(); if(pad.get_direction() == N){currentPage = PAGE_2;} if(pad.check_event(Gamepad::B_PRESSED) == true){ @@ -314,7 +314,7 @@ lcd.printString("signal for",0,2); lcd.printString("the switch is",0,3); lcd.printString("closed for",0,4); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_5;} if(pad.get_direction() == N){currentPage = PAGE_4;} @@ -327,7 +327,7 @@ lcd.printString("what is the",0,2); lcd.printString("switching",0,3); lcd.printString("frequency?",0,4); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_6;} if(pad.get_direction() == N){currentPage = PAGE_4;} @@ -347,7 +347,7 @@ lcd.printString("X. $%^&*",0,4); lcd.printString("Y. $%^&*",0,5); } - lcd.drawSprite(39, 0, 4, 7, up); + lcd.drawSprite(39, 0, 4, 7, (int*)up); lcd.refresh(); if(pad.get_direction() == N){currentPage = PAGE_5;} if(pad.check_event(Gamepad::A_PRESSED) == true){ @@ -368,7 +368,7 @@ lcd.printString("signal with",0,2); lcd.printString("x(t)=0 for t>2",0,3); lcd.printString("and t<6. What",0,4); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_8;} if(pad.get_direction() == N){currentPage = PAGE_7;} @@ -379,7 +379,7 @@ lcd.printString("is the value",0,0); lcd.printString("of x(-t+5) at",0,1); lcd.printString("t=0?",0,2); - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_9;} if(pad.get_direction() == N){currentPage = PAGE_7;} @@ -399,7 +399,7 @@ lcd.printString("X. $%^&*",0,4); lcd.printString("Y. $%^&*",0,5); } - lcd.drawSprite(39, 0, 4, 7, up); + lcd.drawSprite(39, 0, 4, 7, (int*)up); lcd.refresh(); if(pad.get_direction() == N){currentPage = PAGE_8;} if(pad.check_event(Gamepad::Y_PRESSED) == true){ @@ -433,17 +433,17 @@ Page currentPage = PAGE_1; int fps = 8.0; int score = 0; - static int down[] = { - 1,1,1,1,1,1,1, - 0,1,1,1,1,1,0, - 0,0,1,1,1,0,0, - 0,0,0,1,0,0,0 + int down[4][7] = { + {1,1,1,1,1,1,1}, + {0,1,1,1,1,1,0}, + {0,0,1,1,1,0,0}, + {0,0,0,1,0,0,0}, }; - static int up[] = { - 0,0,0,1,0,0,0, - 0,0,1,1,1,0,0, - 0,1,1,1,1,1,0, - 1,1,1,1,1,1,1 + int up[4][7] = { + {0,0,0,1,0,0,0}, + {0,0,1,1,1,0,0}, + {0,1,1,1,1,1,0}, + {1,1,1,1,1,1,1}, }; bool finished = false; @@ -463,7 +463,7 @@ lcd.printString("$%^&*$%^&*",0,2); lcd.printString("$%^&*$%^&*",0,3); } - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_2;} if(pad.get_direction() == N){currentPage = PAGE_1;} @@ -483,7 +483,7 @@ lcd.printString("X. $%^&*",0,4); lcd.printString("Y. $%^&*",0,5); } - lcd.drawSprite(39, 0, 4, 7, up); + lcd.drawSprite(39, 0, 4, 7, (int*)up); lcd.refresh(); if(pad.get_direction() == N){currentPage = PAGE_1;} if(pad.check_event(Gamepad::A_PRESSED) == true){ @@ -510,7 +510,7 @@ lcd.printString("$%^&*$%^&*",0,2); lcd.printString("$%^&*$%^&*",0,3); } - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_4;} if(pad.get_direction() == N){currentPage = PAGE_3;} @@ -530,7 +530,7 @@ lcd.printString("X. $%^&*",0,4); lcd.printString("Y. $%^&*",0,5); } - lcd.drawSprite(39, 0, 4, 7, up); + lcd.drawSprite(39, 0, 4, 7, (int*)up); lcd.refresh(); if(pad.get_direction() == N){currentPage = PAGE_3;} if(pad.check_event(Gamepad::B_PRESSED) == true){ @@ -557,7 +557,7 @@ lcd.printString("$%^&*$%^&*",0,2); lcd.printString("$%^&*$%^&*",0,3); } - lcd.drawSprite(39, 44, 4, 7, down); + lcd.drawSprite(39, 44, 4, 7, (int*)down); lcd.refresh(); if(pad.get_direction() == S){currentPage = PAGE_6;} if(pad.get_direction() == N){currentPage = PAGE_5;} @@ -577,7 +577,7 @@ lcd.printString("X. $%^&*",0,4); lcd.printString("Y. $%^&*",0,5); } - lcd.drawSprite(39, 0, 4, 7, up); + lcd.drawSprite(39, 0, 4, 7, (int*)up); lcd.refresh(); if(pad.get_direction() == N){currentPage = PAGE_5;} if(pad.check_event(Gamepad::Y_PRESSED) == true){