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.
Dependencies: mbed
Fork of el17dg by
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 GameObject smallStar; 00015 GameObject mediumStar; 00016 00017 /**@brief 00018 * This function just displays some strings of the dysplaye to tell the player 00019 * how to use the controls and what to do. 00020 */ 00021 bool Tutorial::updateAndWriteTutorial(){ 00022 turnPages(); 00023 drawArrowsAndExitButton(); 00024 00025 if (current_page == 0){ tutorialPage0();} 00026 else if (current_page == 1){ tutorialPage1();} 00027 else if (current_page == 2){ tutorialPage2();} 00028 else if (current_page == 3){ tutorialPage3();} 00029 else if (current_page == 4){ tutorialPage4();} 00030 else if (current_page == 5){ tutorialPage5();} 00031 else if (current_page == 6){ tutorialPage6();} 00032 else if (current_page == 7){ tutorialPage7();} 00033 else if (current_page == 8){ tutorialPage8();} 00034 else if (current_page == 9){ tutorialPage9();} 00035 else if (current_page == 10){ tutorialPage10();} 00036 else if (current_page == 11){ tutorialPage11();} 00037 00038 bool back_to_menu = false; 00039 if (gamepad.check_event(gamepad.B_PRESSED)){ 00040 gamepad.check_event(gamepad.B_PRESSED); 00041 gamepad.check_event(gamepad.A_PRESSED); 00042 back_to_menu = true; 00043 } 00044 return back_to_menu; 00045 } 00046 00047 void Tutorial::drawArrowsAndExitButton(){ 00048 char buffer[16]; 00049 sprintf(buffer,"page #%i", current_page); 00050 lcd.printString(buffer,20,0); 00051 00052 arrowLeft.pos.x = left_arrow_pos_x; 00053 arrowLeft.pos.y = arrows_pos_y; 00054 arrowRight.pos.x = right_arrow_pos_x; 00055 arrowRight.pos.y = arrows_pos_y; 00056 smallStar.pos.x = 10; 00057 smallStar.pos.y = 10; 00058 mediumStar.pos.x = 10; 00059 mediumStar.pos.y = 15; 00060 00061 drawSprite(arrowRight.pos, tutorial_arrow_right_sprite); 00062 drawSprite(arrowLeft.pos, tutorial_arrow_left_sprite); 00063 lcd.printString("Push B to Exit",0,5); 00064 } 00065 00066 void Tutorial::turnPages(){ 00067 if(x_dir.read() > joy_threshold_max_x){ 00068 current_page -= 1; 00069 wait_ms(time_delay); 00070 } 00071 else if (x_dir.read() < joy_threshold_min_x){ 00072 current_page += 1; 00073 wait_ms(time_delay); 00074 } 00075 if (current_page < 0) { 00076 current_page += total_pages; 00077 } 00078 if (current_page >= total_pages) { 00079 current_page -= total_pages; 00080 } 00081 } 00082 00083 void Tutorial::tutorialPage0(){ 00084 lcd.printString("X - shoot",0,1); 00085 lcd.printString("START - Pause",0,2); 00086 lcd.printString("JOYSTICK - is ",0,3); 00087 lcd.printString("ship movement",0,4); 00088 } 00089 00090 void Tutorial::tutorialPage1(){ 00091 lcd.printString("Shield is ",0,1); 00092 lcd.printString("Activaed/ ",0,2); 00093 lcd.printString("Deactivated by",0,3); 00094 lcd.printString("R button ",0,4); 00095 } 00096 00097 void Tutorial::tutorialPage2(){ 00098 lcd.printString("Shield only",0,1); 00099 lcd.printString("blocks blasts.",0,2); 00100 lcd.printString("Doesn't block",0,3); 00101 lcd.printString("enemy clash",0,4); 00102 } 00103 00104 void Tutorial::tutorialPage3(){ 00105 lcd.printString("When shield",0,1); 00106 lcd.printString("is ON, shooitg",0,2); 00107 lcd.printString("is deactivated",0,3); 00108 } 00109 00110 void Tutorial::tutorialPage4(){ 00111 lcd.printString("You have to",0,1); 00112 lcd.printString("switch between",0,2); 00113 lcd.printString("offence and",0,3); 00114 lcd.printString("deffence",0,4); 00115 } 00116 00117 void Tutorial::tutorialPage5(){ 00118 lcd.printString("Evade or block",0,1); 00119 lcd.printString("enemy shots",0,2); 00120 lcd.printString("and don't let ",0,3); 00121 lcd.printString("them pass.",0,4); 00122 } 00123 00124 void Tutorial::tutorialPage6(){ 00125 lcd.printString("Your health is",0,1); 00126 lcd.printString("shown below",0,2); 00127 lcd.printString("the screen ",0,3); 00128 lcd.printString("It's LEDs. ",0,4); 00129 } 00130 00131 void Tutorial::tutorialPage7(){ 00132 lcd.printString("Kill the ",5,2); 00133 lcd.printString("Enemies!!! ",10,3); 00134 } 00135 00136 void Tutorial::tutorialPage8(){ 00137 lcd.printString("foe died= 30",0,1); 00138 lcd.printString("miss shot= -10",0,2); 00139 lcd.printString("foe left= -50",0,3); 00140 lcd.printString("Be careful ",10,4); 00141 } 00142 00143 void Tutorial::tutorialPage9(){ 00144 lcd.printString("As your score",0,1); 00145 lcd.printString("increase, so ",0,2); 00146 lcd.printString("does the game ",0,3); 00147 lcd.printString("difficulty ",10,4); 00148 } 00149 00150 void Tutorial::tutorialPage10(){ 00151 drawSprite(smallStar.pos, small_star_sprite); 00152 drawSprite(mediumStar.pos, medium_star_sprite); 00153 lcd.printString("S Star",20,1); 00154 lcd.printString("M Star ",20,2); 00155 lcd.printString("They do not ",0,3); 00156 lcd.printString("hurt you ",30,4); 00157 } 00158 00159 void Tutorial::tutorialPage11(){ 00160 lcd.printString("Good Luck!!! ",0,3); 00161 } 00162
Generated on Thu Jul 14 2022 14:15:02 by
1.7.2
