contains my game for the embedded systems project 2645

Dependencies:   mbed FXOS8700CQQQ

GameTests/tests.cpp

Committer:
OmarAlebiary
Date:
2019-04-25
Revision:
29:e660274d8222
Parent:
28:39607fb67e88
Child:
33:24ef796ff2c8

File content as of revision 29:e660274d8222:

#include "tests.h"

//testing menus
////////////////////////////////////////////////

tests::tests(){
    
}

tests::~tests(){
    
}
void tests::test_welcomeMenu(Gamepad &pad,N5110 &lcd){
    menu.welcomeMenu(pad,lcd);
}

void tests::test_Play_Welcome_Melody(Gamepad &pad){
    Game_Tones.Play_Welcome_Melody(pad);
}

void tests::test_End_Game_Melody(Gamepad &pad){
    Game_Tones.End_Game_Melody(pad);
    }
void tests::test_drawMenu(N5110 &lcd,Gamepad &pad){
    menu.drawMenu(lcd,pad);
    }
    
void tests::test_credits_page(N5110 &lcd,Gamepad &pad){
    menu.credits(lcd,pad);
}

void tests::test_loading_menu(N5110 &lcd){
    menu.loading_menu(lcd);
}

void tests::test_InstructionsMenu(Gamepad &pad,N5110 &lcd){
    menu.InstructionsMenu(pad,lcd);
}

///////////////////////////////////////////////
bool tests::test_Joystick_position(Gamepad &pad){

    Direction d=pad.get_direction();//assigning the object d to the method to get the joystick direction

    if( (d==E||pad.check_event(Gamepad::R_PRESSED) == true )){//statement to check if the joystick moved right  
        printf("its Right\n");
        return true;
    }
    else if( (d==W ||pad.check_event(Gamepad::L_PRESSED) == true )){//statement to check if the joystick moved left
        printf("its left\n");
        return true;
    }
    else if(d==CENTRE){//statement to check if the joystick position is center
        wait(0.01);
        printf("its center\n");
        return true;
        }
        return false;
}


bool tests::test_Generate_New_Enemy(){
  
    srand(time(NULL));//seeding the random function
    
    int second_enemy_position = (rand() % 3)+1;//generates a random number from 1 to 3 
    printf("%d",second_enemy_position);
    if(second_enemy_position==1||second_enemy_position==2||second_enemy_position==3){
        return true;
        }
        return false;

}

//testing game loop
////////////////////////////////////////////////
void tests::test_Game_Loop(Gamepad &pad,N5110 &lcd){
    while(1){
        Rocket_Racing.Game_Loop(lcd,pad);
    }
    
}