Library containing the Game Engine

Revision:
12:6eeb06ed7c6b
Parent:
11:832eb031310b
Child:
13:63013a418903
--- a/GameEngine.cpp	Thu May 04 08:34:38 2017 +0000
+++ b/GameEngine.cpp	Thu May 04 09:54:21 2017 +0000
@@ -27,24 +27,26 @@
 
 void GameEngine::draw(N5110 &lcd, Gamepad &pad)
 {
-    _p.draw(lcd); //Draws the Player Sprite.
-    /*while ( pad.check_event(Gamepad::A_PRESSED) == true) {
-        _proj.draw(lcd);
-    }*/
-    
-    //PROJ SPAWN, IF N = N +1, PROJ END, N-1
-    
+    _p.draw(lcd); //Draws the Player Sprite.        
     _proj.draw(lcd); //Draws the Projectile.
     _t.draw(lcd); //Draws the first target.
     _tt.draw(lcd); //Draws the second target.
     _ttt.draw(lcd); //Draws the third target.
     _hb.draw(lcd); //Draws the health bar.
     
+    char bufferscore[14];
+    sprintf(bufferscore,"%d",score);
+    lcd.printString(bufferscore,1,0);
+    
+    
+    
     if(_hb.ZeroHP == 1){ //Checks if health bar is empty. //Working
         
         lcd.clear(); 
         lcd.printString("   You Lose    ",0,1);  
-        lcd.printString("   Press A  ",0,4);
+        lcd.printString("  Score =   ",0,3);
+        lcd.printString(bufferscore,WIDTH/2 + 20,3); 
+        lcd.printString("   Press A  ",0,5);
         lcd.refresh();
         
         while(1){
@@ -62,8 +64,8 @@
 
 void GameEngine::update(Gamepad &pad) //Updates objects on screen.
 {
-    _p.update(_d,_mag);
-    _proj.update(); 
+    _p.update(_d,_mag); 
+    _proj.update();  
     _t.update();
     _tt.update();
     _ttt.update();
@@ -111,15 +113,15 @@
     //bottom of the screen, if so then HP is deducted using the HPLost2 variable.
     
     if(t_pos.y == 47){
-        printf("t floor \n");
+        //printf("t floor \n");
         HPLost2 = HPLost2 - 1;
         }
     if(tt_pos.y == 47){
-        printf("tt floor \n");
+        //printf("tt floor \n");
         HPLost2 = HPLost2 - 1;
         }
     if(ttt_pos.y == 47){
-        printf("ttt floor \n");
+        //printf("ttt floor \n");
         HPLost2 = HPLost2 - 1;
         }
         
@@ -199,6 +201,7 @@
         t_pos.y = 0;
         // audio feedback
         //pad.tone(1000.0,0.1);
+        score = score + 1;
     }
     
     if (
@@ -246,6 +249,7 @@
         tt_pos.y = 0;
         // audio feedback
         //pad.tone(1000.0,0.1);
+        score = score + 1;
     }
     
     if (
@@ -293,6 +297,7 @@
         ttt_pos.y = 0;
         // audio feedback
         //pad.tone(1000.0,0.1);
+        score = score + 1;
     }