ELEC2645 (2017/18) / Mbed 2 deprecated el17yw

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
RickYu
Date:
Mon Apr 23 22:36:11 2018 +0000
Parent:
14:a4176da69b49
Child:
16:75122d14153c
Commit message:
add score while not work.....

Changed in this revision

engine/engine.cpp Show annotated file Show diff for this revision Revisions of this file
rec/rect.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/engine/engine.cpp	Mon Apr 23 22:18:33 2018 +0000
+++ b/engine/engine.cpp	Mon Apr 23 22:36:11 2018 +0000
@@ -142,6 +142,7 @@
              money_pos.y = 0;  
              money_pos.x = rand()%84; 
              pad.tone(750.0,0.1);
+             _rect.add_score();
              //engine::print_scores(lcd);
             }
 
@@ -153,8 +154,13 @@
 
 void engine::print_scores(N5110 &lcd)
 {
-
+    int rect_score = _rect.get_score();
+    char buffer1[14];
+    
     lcd.clear();
+    sprintf(buffer1,"%2d",rect_score);
+    lcd.printString(buffer1,WIDTH/2 - 20,1);
+    
     lcd.printString("  Game Over",0,1);  
     lcd.refresh();
     wait(2);
--- a/rec/rect.cpp	Mon Apr 23 22:18:33 2018 +0000
+++ b/rec/rect.cpp	Mon Apr 23 22:36:11 2018 +0000
@@ -13,6 +13,7 @@
 {
     //set the rect move speed
     rect_speed = 0.5;  // default speed
+    rect_score = 10;
 }
 
 void rect::draw(N5110 &lcd)
@@ -55,7 +56,6 @@
 void rect::set_pos(Vector2D p)
 {
     rect_x = p.x;
-   //rect_y = p.y;
 }