contains my game for the embedded systems project 2645
Dependencies: mbed FXOS8700CQQQ
main.cpp@22:3e6ff378d651, 2019-04-18 (annotated)
- Committer:
- OmarAlebiary
- Date:
- Thu Apr 18 23:13:24 2019 +0000
- Revision:
- 22:3e6ff378d651
- Child:
- 23:2ca9735b16ef
added Menus.cpp and .h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OmarAlebiary | 22:3e6ff378d651 | 1 | #include "mbed.h" |
OmarAlebiary | 22:3e6ff378d651 | 2 | #include "N5110.h" |
OmarAlebiary | 22:3e6ff378d651 | 3 | #include "Gamepad.h" |
OmarAlebiary | 22:3e6ff378d651 | 4 | #include "RocketRacer.h" |
OmarAlebiary | 22:3e6ff378d651 | 5 | #include "Menus.h" |
OmarAlebiary | 22:3e6ff378d651 | 6 | // objects |
OmarAlebiary | 22:3e6ff378d651 | 7 | |
OmarAlebiary | 22:3e6ff378d651 | 8 | /** |
OmarAlebiary | 22:3e6ff378d651 | 9 | * @brief initializing the Gamepad object |
OmarAlebiary | 22:3e6ff378d651 | 10 | */ |
OmarAlebiary | 22:3e6ff378d651 | 11 | Gamepad pad; |
OmarAlebiary | 22:3e6ff378d651 | 12 | /** |
OmarAlebiary | 22:3e6ff378d651 | 13 | * @brief initializing the RocketRacer object |
OmarAlebiary | 22:3e6ff378d651 | 14 | */ |
OmarAlebiary | 22:3e6ff378d651 | 15 | RocketRacer Rocket_Racer; |
OmarAlebiary | 22:3e6ff378d651 | 16 | /** |
OmarAlebiary | 22:3e6ff378d651 | 17 | * @brief initializing the lcd object and assigning the pins on the gamepad to it |
OmarAlebiary | 22:3e6ff378d651 | 18 | */ |
OmarAlebiary | 22:3e6ff378d651 | 19 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
OmarAlebiary | 22:3e6ff378d651 | 20 | /** |
OmarAlebiary | 22:3e6ff378d651 | 21 | * @brief initializing the Menus object |
OmarAlebiary | 22:3e6ff378d651 | 22 | */ |
OmarAlebiary | 22:3e6ff378d651 | 23 | Menus menus; |
OmarAlebiary | 22:3e6ff378d651 | 24 | |
OmarAlebiary | 22:3e6ff378d651 | 25 | // prototypes |
OmarAlebiary | 22:3e6ff378d651 | 26 | /** |
OmarAlebiary | 22:3e6ff378d651 | 27 | * @brief object initialization method |
OmarAlebiary | 22:3e6ff378d651 | 28 | * @param None @details method that initializes objects like lcd,gampad and sets the default |
OmarAlebiary | 22:3e6ff378d651 | 29 | * contrast of the lcd and brightness |
OmarAlebiary | 22:3e6ff378d651 | 30 | */ |
OmarAlebiary | 22:3e6ff378d651 | 31 | void setup(); |
OmarAlebiary | 22:3e6ff378d651 | 32 | /** |
OmarAlebiary | 22:3e6ff378d651 | 33 | * @brief main method |
OmarAlebiary | 22:3e6ff378d651 | 34 | * @param None @details main method that has all the method calls of the Menus.cpp and |
OmarAlebiary | 22:3e6ff378d651 | 35 | * the RocketRacer class and has the Game_Loop method that runs the game |
OmarAlebiary | 22:3e6ff378d651 | 36 | */ |
OmarAlebiary | 22:3e6ff378d651 | 37 | int main(); |
OmarAlebiary | 22:3e6ff378d651 | 38 | |
OmarAlebiary | 22:3e6ff378d651 | 39 | |
OmarAlebiary | 22:3e6ff378d651 | 40 | |
OmarAlebiary | 22:3e6ff378d651 | 41 | void setup(){ |
OmarAlebiary | 22:3e6ff378d651 | 42 | |
OmarAlebiary | 22:3e6ff378d651 | 43 | lcd.init();//initialize the lcd |
OmarAlebiary | 22:3e6ff378d651 | 44 | pad.init();//initialize the pad |
OmarAlebiary | 22:3e6ff378d651 | 45 | lcd.clear(); |
OmarAlebiary | 22:3e6ff378d651 | 46 | lcd.setBrightness(0.4);//sets the default brightness |
OmarAlebiary | 22:3e6ff378d651 | 47 | lcd.setContrast(0.55);//set the default contrast |
OmarAlebiary | 22:3e6ff378d651 | 48 | lcd.normalMode(); |
OmarAlebiary | 22:3e6ff378d651 | 49 | |
OmarAlebiary | 22:3e6ff378d651 | 50 | } |
OmarAlebiary | 22:3e6ff378d651 | 51 | |
OmarAlebiary | 22:3e6ff378d651 | 52 | |
OmarAlebiary | 22:3e6ff378d651 | 53 | |
OmarAlebiary | 22:3e6ff378d651 | 54 | |
OmarAlebiary | 22:3e6ff378d651 | 55 | int main(){ |
OmarAlebiary | 22:3e6ff378d651 | 56 | |
OmarAlebiary | 22:3e6ff378d651 | 57 | |
OmarAlebiary | 22:3e6ff378d651 | 58 | setup(); |
OmarAlebiary | 22:3e6ff378d651 | 59 | menus.welcomeMenu(pad,lcd); |
OmarAlebiary | 22:3e6ff378d651 | 60 | |
OmarAlebiary | 22:3e6ff378d651 | 61 | menus.InstructionsMenu(pad,lcd); |
OmarAlebiary | 22:3e6ff378d651 | 62 | //keeps looping untill the player loses |
OmarAlebiary | 22:3e6ff378d651 | 63 | while(1){ |
OmarAlebiary | 22:3e6ff378d651 | 64 | Rocket_Racer.Game_Loop(lcd,pad); |
OmarAlebiary | 22:3e6ff378d651 | 65 | } |
OmarAlebiary | 22:3e6ff378d651 | 66 | |
OmarAlebiary | 22:3e6ff378d651 | 67 | |
OmarAlebiary | 22:3e6ff378d651 | 68 | } |
OmarAlebiary | 22:3e6ff378d651 | 69 |