![](/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:
- 15:8a768106c297
- Parent:
- 14:8df7e6fced07
- Child:
- 16:93a8147a4358
--- a/GameEngine/RocketRacer.cpp Wed Apr 03 09:18:15 2019 +0000 +++ b/GameEngine/RocketRacer.cpp Sun Apr 07 18:19:48 2019 +0000 @@ -3,6 +3,7 @@ DigitalIn buttonL(PTB18); DigitalIn buttonR(PTB3); + const int enemy[11][9] = { { 0,0,0,0,1,0,0,0,0 }, { 0,0,0,1,1,1,0,0,0 }, @@ -32,17 +33,10 @@ }; - -RocketRacer::RocketRacer(){ - - first_enemy_position=0, second_enemy_position=0, enemy_phase=0; - game_speed = 0; - score = 0; - Init_position=2; - enemy_dead = true; - control = true; - -} +RocketRacer::RocketRacer() +:first_enemy_position(0),second_enemy_position(0),enemy_phase(0), +game_speed (0),score(0),Init_position(2),enemy_dead(true),control(true) +{} void RocketRacer::Main_Game_Display(N5110 &lcd){ @@ -54,7 +48,7 @@ char level_buffer1[14]; buttonL.mode(PullDown); buttonR.mode(PullDown); - + //dispaly score sprintf(score_buffer,"score"); lcd.printString(score_buffer,55,0); @@ -77,16 +71,16 @@ if((d==E||buttonR==true) && Init_position!=3 && control==true){ Init_position++; control = false; - printf("its Right\n"); +// printf("its Right\n"); } else if((d==W ||buttonL==true)&& Init_position!=1 && control==true){ Init_position--; control = false; - printf("its left\n"); +// printf("its left\n"); } else if(d==CENTRE){ control = true; - printf("its center\n"); +// printf("its center\n"); } } @@ -105,11 +99,10 @@ void RocketRacer::Check_Enemy_Dead(N5110 &lcd,Gamepad &pad){ - if (enemy_phase>22 && ((first_enemy_position== Init_position) || (second_enemy_position == Init_position)) ){ - End_Game(pad,lcd); - + if (enemy_phase>23 && ((first_enemy_position== Init_position) || (second_enemy_position == Init_position)) ){ + End_Game(pad,lcd); } - if (enemy_phase>40){ + if (enemy_phase>39){ enemy_dead = true; score++; } @@ -164,7 +157,7 @@ if (score>25 && score<=30){ pad.led(5,1.0); game_speed = 4; - wait(0.05); + wait(0.04); } if (score>30){ pad.led(6,1.0); @@ -195,7 +188,6 @@ Main_Game_Display(lcd); - if (RocketPosition==1){ lcd.drawSprite(2,34,11,9,(int *)rocket); }