Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
tutorial.cpp
00001 #include "main.h" 00002 #include "menu.h" 00003 #include "tutorial.h" 00004 #include "constants.h" 00005 #include "models.h" 00006 #include "gameobject.h" 00007 00008 Tutorial::Tutorial() { 00009 current_page = 0; 00010 } 00011 00012 GameObject arrowLeft; 00013 GameObject arrowRight; 00014 00015 /**@brief 00016 * This function just displays some strings of the dysplaye to tell the player 00017 * how to use the controls and what to do. 00018 */ 00019 bool Tutorial::updateAndWriteTutorial(){ 00020 turnPages(); 00021 drawArrowsAndExitButton(); 00022 00023 if (current_page == 0){ tutorialPage0();} 00024 else if (current_page == 1){ tutorialPage1();} 00025 else if (current_page == 2){ tutorialPage2();} 00026 else if (current_page == 3){ tutorialPage3();} 00027 else if (current_page == 4){ tutorialPage4();} 00028 else if (current_page == 5){ tutorialPage5();} 00029 else if (current_page == 6){ tutorialPage6();} 00030 else if (current_page == 7){ tutorialPage7();} 00031 else if (current_page == 8){ tutorialPage8();} 00032 else if (current_page == 9){ tutorialPage9();} 00033 else if (current_page == 10){ tutorialPage10();} 00034 00035 bool back_to_menu = false; 00036 if (gamepad.check_event(gamepad.B_PRESSED)){ 00037 gamepad.check_event(gamepad.B_PRESSED); 00038 back_to_menu = true; 00039 } 00040 return back_to_menu; 00041 } 00042 00043 void Tutorial::drawArrowsAndExitButton(){ 00044 char buffer[16]; 00045 sprintf(buffer,"page #%i", current_page); 00046 lcd.printString(buffer,20,0); 00047 00048 arrowLeft.pos.x = left_arrow_pos_x; 00049 arrowLeft.pos.y = arrows_pos_y; 00050 arrowRight.pos.x = right_arrow_pos_x; 00051 arrowRight.pos.y = arrows_pos_y; 00052 00053 drawSprite(arrowRight.pos, tutorial_arrow_right_sprite); 00054 drawSprite(arrowLeft.pos, tutorial_arrow_left_sprite); 00055 lcd.printString("Push B to Exit",0,5); 00056 } 00057 00058 void Tutorial::turnPages(){ 00059 if(x_dir.read() > joy_threshold_max_x){ 00060 current_page -= 1; 00061 wait_ms(time_delay); 00062 } 00063 else if (x_dir.read() < joy_threshold_min_x){ 00064 current_page += 1; 00065 wait_ms(time_delay); 00066 } 00067 if (current_page < 0) { 00068 current_page += total_pages; 00069 } 00070 if (current_page >= total_pages) { 00071 current_page -= total_pages; 00072 } 00073 } 00074 00075 void Tutorial::tutorialPage0(){ 00076 lcd.printString("X - shoot",0,1); 00077 lcd.printString("START - Pause",0,2); 00078 lcd.printString("JOYSTICK - is ",0,3); 00079 lcd.printString("ship movement",0,4); 00080 } 00081 00082 void Tutorial::tutorialPage1(){ 00083 lcd.printString("Shield is ",0,1); 00084 lcd.printString("Activaed/ ",0,2); 00085 lcd.printString("Deactivated by",0,3); 00086 lcd.printString("R button ",0,4); 00087 } 00088 00089 void Tutorial::tutorialPage2(){ 00090 lcd.printString("Shield only",0,1); 00091 lcd.printString("blocks blasts.",0,2); 00092 lcd.printString("Doesn't block",0,3); 00093 lcd.printString("enemy clash",0,4); 00094 } 00095 00096 void Tutorial::tutorialPage3(){ 00097 lcd.printString("When shield",0,1); 00098 lcd.printString("is ON, shooitg",0,2); 00099 lcd.printString("is deactivated",0,3); 00100 } 00101 00102 void Tutorial::tutorialPage4(){ 00103 lcd.printString("You have to",0,1); 00104 lcd.printString("switch between",0,2); 00105 lcd.printString("offence and",0,3); 00106 lcd.printString("deffence",0,4); 00107 } 00108 00109 void Tutorial::tutorialPage5(){ 00110 lcd.printString("Evade or block",0,1); 00111 lcd.printString("enemy shots",0,2); 00112 lcd.printString("and don't let ",0,3); 00113 lcd.printString("them pass.",0,4); 00114 } 00115 00116 void Tutorial::tutorialPage6(){ 00117 lcd.printString("Your health is",0,1); 00118 lcd.printString("shown below",0,2); 00119 lcd.printString("the screen ",0,3); 00120 lcd.printString("It's LEDs. ",0,4); 00121 } 00122 00123 void Tutorial::tutorialPage7(){ 00124 lcd.printString("Kill the ",5,2); 00125 lcd.printString("Enemies!!! ",10,3); 00126 } 00127 00128 void Tutorial::tutorialPage8(){ 00129 lcd.printString("foe died= 30",0,1); 00130 lcd.printString("miss shot= -10",0,2); 00131 lcd.printString("foe left= -50",0,3); 00132 lcd.printString("Be careful ",10,4); 00133 } 00134 00135 void Tutorial::tutorialPage9(){ 00136 lcd.printString("As your score",0,1); 00137 lcd.printString("increase, so ",0,2); 00138 lcd.printString("does the game ",0,3); 00139 lcd.printString("difficulty ",10,4); 00140 } 00141 00142 void Tutorial::tutorialPage10(){ 00143 lcd.printString("Good Luck!!! ",0,3); 00144 } 00145
Generated on Wed Dec 20 2023 20:30:17 by
