contains my game for the embedded systems project 2645

Dependencies:   mbed FXOS8700CQQQ

Committer:
OmarAlebiary
Date:
Wed Apr 24 10:19:07 2019 +0000
Revision:
28:39607fb67e88
Child:
29:e660274d8222
added doxygen comments to RocketRacer.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
OmarAlebiary 28:39607fb67e88 1 #include "Menus.h"
OmarAlebiary 28:39607fb67e88 2
OmarAlebiary 28:39607fb67e88 3
OmarAlebiary 28:39607fb67e88 4
OmarAlebiary 28:39607fb67e88 5 Menus::Menus(){
OmarAlebiary 28:39607fb67e88 6 }
OmarAlebiary 28:39607fb67e88 7
OmarAlebiary 28:39607fb67e88 8 void Menus::welcomeMenu(Gamepad &pad,N5110 &lcd) {
OmarAlebiary 28:39607fb67e88 9
OmarAlebiary 28:39607fb67e88 10 lcd.printString(" Rocket Racer ",0,0);
OmarAlebiary 28:39607fb67e88 11
OmarAlebiary 28:39607fb67e88 12 lcd.drawSprite(25,8,11,9,(int *)enemyMainMenu);
OmarAlebiary 28:39607fb67e88 13 lcd.drawSprite(45,15,11,9,(int *)enemyMainMenu);
OmarAlebiary 28:39607fb67e88 14 lcd.drawSprite(35,31,11,9,(int *)rocketMainMenu);
OmarAlebiary 28:39607fb67e88 15 lcd.drawLine(20, 10, 20,45,1);
OmarAlebiary 28:39607fb67e88 16 lcd.drawLine(22, 10, 22,45,2);
OmarAlebiary 28:39607fb67e88 17 lcd.drawLine(57, 10, 57,45,1);
OmarAlebiary 28:39607fb67e88 18 lcd.drawLine(55, 10, 55,45,2);
OmarAlebiary 28:39607fb67e88 19
OmarAlebiary 28:39607fb67e88 20 pad.leds_on();//turns all leds on
OmarAlebiary 28:39607fb67e88 21 lcd.refresh();
OmarAlebiary 28:39607fb67e88 22 tone.Play_Welcome_Melody(pad);
OmarAlebiary 28:39607fb67e88 23 wait(1);
OmarAlebiary 28:39607fb67e88 24
OmarAlebiary 28:39607fb67e88 25 }
OmarAlebiary 28:39607fb67e88 26
OmarAlebiary 28:39607fb67e88 27
OmarAlebiary 28:39607fb67e88 28 void Menus::drawMenu(N5110 &lcd,Gamepad &pad) {
OmarAlebiary 28:39607fb67e88 29
OmarAlebiary 28:39607fb67e88 30 lcd.clear();
OmarAlebiary 28:39607fb67e88 31 lcd.printString("MAIN MENU", 15, 0);
OmarAlebiary 28:39607fb67e88 32 lcd.drawLine(1, 10,80 ,10,1);
OmarAlebiary 28:39607fb67e88 33 lcd.printString("Play -A", 2, 2);
OmarAlebiary 28:39607fb67e88 34 lcd.printString("Instructions-B", 1, 3);
OmarAlebiary 28:39607fb67e88 35 lcd.printString("Credits - X", 1, 4);
OmarAlebiary 28:39607fb67e88 36 pad.leds_off();
OmarAlebiary 28:39607fb67e88 37 wait(0.1);
OmarAlebiary 28:39607fb67e88 38 pad.leds_on();
OmarAlebiary 28:39607fb67e88 39 wait(0.1);
OmarAlebiary 28:39607fb67e88 40 lcd.refresh();
OmarAlebiary 28:39607fb67e88 41
OmarAlebiary 28:39607fb67e88 42 check_button_pressed(pad,lcd);
OmarAlebiary 28:39607fb67e88 43
OmarAlebiary 28:39607fb67e88 44 }
OmarAlebiary 28:39607fb67e88 45
OmarAlebiary 28:39607fb67e88 46
OmarAlebiary 28:39607fb67e88 47 void Menus::check_button_pressed(Gamepad &pad,N5110 &lcd){
OmarAlebiary 28:39607fb67e88 48
OmarAlebiary 28:39607fb67e88 49 if (pad.check_event(Gamepad::A_PRESSED) == true){
OmarAlebiary 28:39607fb67e88 50 pad.leds_off();
OmarAlebiary 28:39607fb67e88 51 while(1){
OmarAlebiary 28:39607fb67e88 52 Rocket_Race.Game_Loop(lcd,pad);
OmarAlebiary 28:39607fb67e88 53 }
OmarAlebiary 28:39607fb67e88 54 }
OmarAlebiary 28:39607fb67e88 55 else if (pad.check_event(Gamepad::B_PRESSED) == true){
OmarAlebiary 28:39607fb67e88 56 InstructionsMenu(pad,lcd);
OmarAlebiary 28:39607fb67e88 57 if (pad.check_event(Gamepad::BACK_PRESSED) == true){
OmarAlebiary 28:39607fb67e88 58 drawMenu(lcd,pad);
OmarAlebiary 28:39607fb67e88 59 }
OmarAlebiary 28:39607fb67e88 60 }
OmarAlebiary 28:39607fb67e88 61 else if (pad.check_event(Gamepad::X_PRESSED) == true){
OmarAlebiary 28:39607fb67e88 62 credits(lcd,pad);
OmarAlebiary 28:39607fb67e88 63 if (pad.check_event(Gamepad::BACK_PRESSED) == true){
OmarAlebiary 28:39607fb67e88 64 drawMenu(lcd,pad);
OmarAlebiary 28:39607fb67e88 65 }
OmarAlebiary 28:39607fb67e88 66 }
OmarAlebiary 28:39607fb67e88 67 }
OmarAlebiary 28:39607fb67e88 68
OmarAlebiary 28:39607fb67e88 69
OmarAlebiary 28:39607fb67e88 70 void Menus::credits(N5110 &lcd,Gamepad &pad) {
OmarAlebiary 28:39607fb67e88 71
OmarAlebiary 28:39607fb67e88 72 lcd.clear();
OmarAlebiary 28:39607fb67e88 73
OmarAlebiary 28:39607fb67e88 74 lcd.printString("Game By:", 8, 1);
OmarAlebiary 28:39607fb67e88 75 lcd.printString("Omar Alebiary", 7, 2);
OmarAlebiary 28:39607fb67e88 76 lcd.printString("ID: 201172644", 7, 3);
OmarAlebiary 28:39607fb67e88 77
OmarAlebiary 28:39607fb67e88 78 lcd.printString("< press BACK ", 12, 5);
OmarAlebiary 28:39607fb67e88 79
OmarAlebiary 28:39607fb67e88 80
OmarAlebiary 28:39607fb67e88 81 lcd.refresh();
OmarAlebiary 28:39607fb67e88 82 wait(0.5);
OmarAlebiary 28:39607fb67e88 83 while ( pad.check_event(Gamepad::BACK_PRESSED) == false){//keep looping since back not pressed
OmarAlebiary 28:39607fb67e88 84 pad.leds_on();//turn all leds on
OmarAlebiary 28:39607fb67e88 85 wait(0.1);
OmarAlebiary 28:39607fb67e88 86 pad.leds_off();//turn all leds off
OmarAlebiary 28:39607fb67e88 87 wait(0.1);
OmarAlebiary 28:39607fb67e88 88
OmarAlebiary 28:39607fb67e88 89 }
OmarAlebiary 28:39607fb67e88 90
OmarAlebiary 28:39607fb67e88 91 }
OmarAlebiary 28:39607fb67e88 92
OmarAlebiary 28:39607fb67e88 93
OmarAlebiary 28:39607fb67e88 94 void Menus::loading_menu(N5110 &lcd) {
OmarAlebiary 28:39607fb67e88 95 lcd.clear();
OmarAlebiary 28:39607fb67e88 96 lcd.printString("loading...", 2, 1);
OmarAlebiary 28:39607fb67e88 97
OmarAlebiary 28:39607fb67e88 98 lcd.drawLine(7, 20,12 ,20,1);
OmarAlebiary 28:39607fb67e88 99 lcd.refresh();
OmarAlebiary 28:39607fb67e88 100 wait(0.6);
OmarAlebiary 28:39607fb67e88 101 lcd.drawLine(7, 20,24 ,20,1);
OmarAlebiary 28:39607fb67e88 102 lcd.refresh();
OmarAlebiary 28:39607fb67e88 103 wait(0.5);
OmarAlebiary 28:39607fb67e88 104 lcd.drawLine(7, 20,34 ,20,1);
OmarAlebiary 28:39607fb67e88 105 lcd.refresh();
OmarAlebiary 28:39607fb67e88 106 wait(0.6);
OmarAlebiary 28:39607fb67e88 107 lcd.drawLine(7, 20,44,20,1);
OmarAlebiary 28:39607fb67e88 108 lcd.refresh();
OmarAlebiary 28:39607fb67e88 109 wait(0.2);
OmarAlebiary 28:39607fb67e88 110 lcd.drawLine(7, 20,65 ,20,1);
OmarAlebiary 28:39607fb67e88 111 lcd.refresh();
OmarAlebiary 28:39607fb67e88 112 wait(0.2);
OmarAlebiary 28:39607fb67e88 113 }
OmarAlebiary 28:39607fb67e88 114
OmarAlebiary 28:39607fb67e88 115
OmarAlebiary 28:39607fb67e88 116 void Menus::InstructionsMenu(Gamepad &pad,N5110 &lcd){
OmarAlebiary 28:39607fb67e88 117
OmarAlebiary 28:39607fb67e88 118 lcd.clear();
OmarAlebiary 28:39607fb67e88 119 lcd.printString("How to play:",0,0);
OmarAlebiary 28:39607fb67e88 120 lcd.printString("Use joystick",0,1);
OmarAlebiary 28:39607fb67e88 121 lcd.printString("or L & R",0,2);
OmarAlebiary 28:39607fb67e88 122 lcd.printString("to escape ",0,3);
OmarAlebiary 28:39607fb67e88 123 lcd.printString("enemies.",0,4);
OmarAlebiary 28:39607fb67e88 124 lcd.printString("< press BACK ", 12, 5);
OmarAlebiary 28:39607fb67e88 125
OmarAlebiary 28:39607fb67e88 126 lcd.refresh();
OmarAlebiary 28:39607fb67e88 127 wait(0.5);
OmarAlebiary 28:39607fb67e88 128 while ( pad.check_event(Gamepad::BACK_PRESSED) == false){//keep looping since back not pressed
OmarAlebiary 28:39607fb67e88 129 pad.leds_on();//turn all leds on
OmarAlebiary 28:39607fb67e88 130 wait(0.1);
OmarAlebiary 28:39607fb67e88 131 pad.leds_off();//turn all leds off
OmarAlebiary 28:39607fb67e88 132 wait(0.1);
OmarAlebiary 28:39607fb67e88 133
OmarAlebiary 28:39607fb67e88 134 }
OmarAlebiary 28:39607fb67e88 135 }
OmarAlebiary 28:39607fb67e88 136
OmarAlebiary 28:39607fb67e88 137
OmarAlebiary 28:39607fb67e88 138
OmarAlebiary 28:39607fb67e88 139
OmarAlebiary 28:39607fb67e88 140