![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
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: main.cpp
- Revision:
- 27:4bcdfb212467
- Parent:
- 26:c60becf3f840
- Child:
- 28:a6726a3f8e6d
--- a/main.cpp Tue Apr 30 09:40:35 2019 +0000 +++ b/main.cpp Mon May 06 01:28:50 2019 +0000 @@ -15,6 +15,7 @@ #include "Start.h" #include "Game_one.h" #include "Game_two.h" +#include "Game_three.h" #include "Exam.h" #include "FXOS8700CQ.h" #include "rtos.h" @@ -26,6 +27,7 @@ Start start; Game_one game_1; Game_two game_2; +Game_three game_3; Exam test; Thread thread; // I2C connection for FXOS8700CQ accelerometer/magnetometer @@ -74,6 +76,8 @@ int game_2_speed = 0; int game_2_cha = 0; int game_2_r = 1; +int game_3_set = 1; +float game_3_time = 1.0; int select = 0; int year = 0; int pass = 0; @@ -186,13 +190,45 @@ // Game loop for Bulbasaur's mini game case BULBASAUR: - score = 3; + int i = 0; + score = 0; + while(i < 3){ + // Indicate for which term the current game is in + if(i == 0) {term_one();} + else if(i == 1) {term_two();} + else{term_three();} + int j = 0; + while(j < 5){ + // Game loop for 5 rounds + game_3.init(pad, game_3_set); + game_3.render(lcd, game_3_set); + game_3.read_input(pad); + wait(game_3_time); + game_3.update(pad, game_3_set); + j = game_3.get_count(); + } + i = i++; + // determine if win condition is met, return score to proceed to EXAM game loop + if(game_3.get_score() >= 4) { + win(); + music.win(pad); + wait(0.5); + score++; + } + else { + lose(); + pad.tone(750.0,0.2); + wait(0.5); + pad.tone(750.0,0.2); + wait(1.0); + } + } currentGame = EXAM; break; // Game loop for Squirtle's mini game case SQUIRTLE: - int i = 0; + i = 0; score = 0; while(i < 3){ // Indicate for which term the current game is in @@ -630,6 +666,8 @@ game_2_speed = 1; game_2_cha = 1; game_2_r = 6; + game_3_set = 1; + game_3_time = 1.0; } // function for drawing year two title screen @@ -685,6 +723,8 @@ game_2_speed = 2; game_2_cha = 2; game_2_r = 5; + game_3_set = 2; + game_3_time = 0.8; } // function for drawing year three title screen @@ -740,6 +780,8 @@ game_2_speed = 2; game_2_cha = 3; game_2_r = 3; + game_3_set = 3; + game_3_time = 0.6; } // function for displaying the game information