contains my game for the embedded systems project 2645
Dependencies: mbed FXOS8700CQQQ
GameTests/tests.cpp@29:e660274d8222, 2019-04-25 (annotated)
- Committer:
- OmarAlebiary
- Date:
- Thu Apr 25 10:44:53 2019 +0000
- Revision:
- 29:e660274d8222
- Parent:
- 28:39607fb67e88
- Child:
- 33:24ef796ff2c8
added doxygen comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OmarAlebiary | 26:35714debc45f | 1 | #include "tests.h" |
OmarAlebiary | 28:39607fb67e88 | 2 | |
OmarAlebiary | 26:35714debc45f | 3 | //testing menus |
OmarAlebiary | 26:35714debc45f | 4 | //////////////////////////////////////////////// |
OmarAlebiary | 28:39607fb67e88 | 5 | |
OmarAlebiary | 28:39607fb67e88 | 6 | tests::tests(){ |
OmarAlebiary | 28:39607fb67e88 | 7 | |
OmarAlebiary | 28:39607fb67e88 | 8 | } |
OmarAlebiary | 29:e660274d8222 | 9 | |
OmarAlebiary | 29:e660274d8222 | 10 | tests::~tests(){ |
OmarAlebiary | 29:e660274d8222 | 11 | |
OmarAlebiary | 29:e660274d8222 | 12 | } |
OmarAlebiary | 26:35714debc45f | 13 | void tests::test_welcomeMenu(Gamepad &pad,N5110 &lcd){ |
OmarAlebiary | 26:35714debc45f | 14 | menu.welcomeMenu(pad,lcd); |
OmarAlebiary | 26:35714debc45f | 15 | } |
OmarAlebiary | 26:35714debc45f | 16 | |
OmarAlebiary | 28:39607fb67e88 | 17 | void tests::test_Play_Welcome_Melody(Gamepad &pad){ |
OmarAlebiary | 28:39607fb67e88 | 18 | Game_Tones.Play_Welcome_Melody(pad); |
OmarAlebiary | 26:35714debc45f | 19 | } |
OmarAlebiary | 28:39607fb67e88 | 20 | |
OmarAlebiary | 28:39607fb67e88 | 21 | void tests::test_End_Game_Melody(Gamepad &pad){ |
OmarAlebiary | 28:39607fb67e88 | 22 | Game_Tones.End_Game_Melody(pad); |
OmarAlebiary | 28:39607fb67e88 | 23 | } |
OmarAlebiary | 26:35714debc45f | 24 | void tests::test_drawMenu(N5110 &lcd,Gamepad &pad){ |
OmarAlebiary | 26:35714debc45f | 25 | menu.drawMenu(lcd,pad); |
OmarAlebiary | 26:35714debc45f | 26 | } |
OmarAlebiary | 26:35714debc45f | 27 | |
OmarAlebiary | 26:35714debc45f | 28 | void tests::test_credits_page(N5110 &lcd,Gamepad &pad){ |
OmarAlebiary | 26:35714debc45f | 29 | menu.credits(lcd,pad); |
OmarAlebiary | 26:35714debc45f | 30 | } |
OmarAlebiary | 26:35714debc45f | 31 | |
OmarAlebiary | 26:35714debc45f | 32 | void tests::test_loading_menu(N5110 &lcd){ |
OmarAlebiary | 26:35714debc45f | 33 | menu.loading_menu(lcd); |
OmarAlebiary | 26:35714debc45f | 34 | } |
OmarAlebiary | 26:35714debc45f | 35 | |
OmarAlebiary | 26:35714debc45f | 36 | void tests::test_InstructionsMenu(Gamepad &pad,N5110 &lcd){ |
OmarAlebiary | 26:35714debc45f | 37 | menu.InstructionsMenu(pad,lcd); |
OmarAlebiary | 26:35714debc45f | 38 | } |
OmarAlebiary | 26:35714debc45f | 39 | |
OmarAlebiary | 29:e660274d8222 | 40 | /////////////////////////////////////////////// |
OmarAlebiary | 29:e660274d8222 | 41 | bool tests::test_Joystick_position(Gamepad &pad){ |
OmarAlebiary | 26:35714debc45f | 42 | |
OmarAlebiary | 29:e660274d8222 | 43 | Direction d=pad.get_direction();//assigning the object d to the method to get the joystick direction |
OmarAlebiary | 29:e660274d8222 | 44 | |
OmarAlebiary | 29:e660274d8222 | 45 | if( (d==E||pad.check_event(Gamepad::R_PRESSED) == true )){//statement to check if the joystick moved right |
OmarAlebiary | 29:e660274d8222 | 46 | printf("its Right\n"); |
OmarAlebiary | 29:e660274d8222 | 47 | return true; |
OmarAlebiary | 29:e660274d8222 | 48 | } |
OmarAlebiary | 29:e660274d8222 | 49 | else if( (d==W ||pad.check_event(Gamepad::L_PRESSED) == true )){//statement to check if the joystick moved left |
OmarAlebiary | 29:e660274d8222 | 50 | printf("its left\n"); |
OmarAlebiary | 29:e660274d8222 | 51 | return true; |
OmarAlebiary | 29:e660274d8222 | 52 | } |
OmarAlebiary | 29:e660274d8222 | 53 | else if(d==CENTRE){//statement to check if the joystick position is center |
OmarAlebiary | 29:e660274d8222 | 54 | wait(0.01); |
OmarAlebiary | 29:e660274d8222 | 55 | printf("its center\n"); |
OmarAlebiary | 29:e660274d8222 | 56 | return true; |
OmarAlebiary | 29:e660274d8222 | 57 | } |
OmarAlebiary | 29:e660274d8222 | 58 | return false; |
OmarAlebiary | 29:e660274d8222 | 59 | } |
OmarAlebiary | 29:e660274d8222 | 60 | |
OmarAlebiary | 29:e660274d8222 | 61 | |
OmarAlebiary | 29:e660274d8222 | 62 | bool tests::test_Generate_New_Enemy(){ |
OmarAlebiary | 29:e660274d8222 | 63 | |
OmarAlebiary | 29:e660274d8222 | 64 | srand(time(NULL));//seeding the random function |
OmarAlebiary | 29:e660274d8222 | 65 | |
OmarAlebiary | 29:e660274d8222 | 66 | int second_enemy_position = (rand() % 3)+1;//generates a random number from 1 to 3 |
OmarAlebiary | 29:e660274d8222 | 67 | printf("%d",second_enemy_position); |
OmarAlebiary | 29:e660274d8222 | 68 | if(second_enemy_position==1||second_enemy_position==2||second_enemy_position==3){ |
OmarAlebiary | 29:e660274d8222 | 69 | return true; |
OmarAlebiary | 29:e660274d8222 | 70 | } |
OmarAlebiary | 29:e660274d8222 | 71 | return false; |
OmarAlebiary | 29:e660274d8222 | 72 | |
OmarAlebiary | 29:e660274d8222 | 73 | } |
OmarAlebiary | 29:e660274d8222 | 74 | |
OmarAlebiary | 29:e660274d8222 | 75 | //testing game loop |
OmarAlebiary | 26:35714debc45f | 76 | //////////////////////////////////////////////// |
OmarAlebiary | 26:35714debc45f | 77 | void tests::test_Game_Loop(Gamepad &pad,N5110 &lcd){ |
OmarAlebiary | 26:35714debc45f | 78 | while(1){ |
OmarAlebiary | 26:35714debc45f | 79 | Rocket_Racing.Game_Loop(lcd,pad); |
OmarAlebiary | 26:35714debc45f | 80 | } |
OmarAlebiary | 26:35714debc45f | 81 | |
OmarAlebiary | 26:35714debc45f | 82 | } |