![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
contains my game for the embedded systems project 2645
Dependencies: mbed FXOS8700CQQQ
Diff: GameEngine/RocketRacer.cpp
- Revision:
- 19:ad9dc8e418c9
- Parent:
- 16:93a8147a4358
- Child:
- 20:1907ef5d29bb
--- a/GameEngine/RocketRacer.cpp Mon Apr 08 18:49:00 2019 +0000 +++ b/GameEngine/RocketRacer.cpp Tue Apr 09 15:33:52 2019 +0000 @@ -1,7 +1,6 @@ #include "RocketRacer.h" -DigitalIn buttonL(PTB18); -DigitalIn buttonR(PTB3); + const int enemy[11][9] = { @@ -46,8 +45,7 @@ char score_buffer1[14]; char level_buffer[14]; char level_buffer1[14]; - buttonL.mode(PullDown); - buttonR.mode(PullDown); + //dispaly score sprintf(score_buffer,"score"); @@ -68,12 +66,14 @@ Direction d=pad.get_direction(); - if((d==E||buttonR==true) && Init_position!=3 && control==true){ + if( (d==E||pad.check_event(Gamepad::R_PRESSED) == true ) + && Init_position!=3 && control==true){ Init_position++; control = false; // printf("its Right\n"); } - else if((d==W ||buttonL==true)&& Init_position!=1 && control==true){ + else if( (d==W ||pad.check_event(Gamepad::L_PRESSED) == true ) + && Init_position!=1 && control==true){ Init_position--; control = false; // printf("its left\n"); @@ -99,7 +99,8 @@ void RocketRacer::Check_Enemy_Dead(N5110 &lcd,Gamepad &pad){ - if (enemy_phase>23 && ((first_enemy_position== Init_position) || (second_enemy_position == Init_position)) ){ + if (enemy_phase>23 && ((first_enemy_position== Init_position) + || (second_enemy_position == Init_position)) ){ End_Game(pad,lcd); } if (enemy_phase>39){