deemo1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
haoyan
Date:
Thu May 14 06:30:39 2020 +0000
Parent:
5:32dbfaf578dd
Commit message:
test

Changed in this revision

Acid/Acid.cpp Show annotated file Show diff for this revision Revisions of this file
Battleship/Battleship.cpp Show annotated file Show diff for this revision Revisions of this file
StarcraftEngine/StarcraftEngine.cpp Show annotated file Show diff for this revision Revisions of this file
mian.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Acid/Acid.cpp	Thu May 14 05:21:50 2020 +0000
+++ b/Acid/Acid.cpp	Thu May 14 06:30:39 2020 +0000
@@ -22,7 +22,7 @@
      srand(time(NULL));
      
      _velocity.x = 0;
-     _velocity.y = 2*speed;
+     _velocity.y = 1.5*speed;
      
 }
 
--- a/Battleship/Battleship.cpp	Thu May 14 05:21:50 2020 +0000
+++ b/Battleship/Battleship.cpp	Thu May 14 06:30:39 2020 +0000
@@ -12,10 +12,11 @@
     
 }
 
-int Battleshipp[3][6] = {
-    { 0,0,1,1,0,0 },
-    { 0,1,1,1,1,0 },
-    { 1,1,1,1,1,1 },  
+int Battleshipp[4][6] = {
+    {0,0,1,1,0,0},
+    {0,0,1,1,0,0},
+    {1,1,1,1,1,1},
+    {1,1,1,1,1,1},  
 };
 
 void Battleship::init(int x,int height, int width)
@@ -26,13 +27,13 @@
      _width = width;
      _speed = 1;  // default speed
      _score = 0;  // start score from zero
-     _life = 1;   // set the life one
+     _life = 3;   // set the life 
 }
  
 void Battleship::draw(N5110 &lcd)
  {
      // draw a battleship in screen buffer. 
-     lcd.drawRect(_x,_y,_width,_height,FILL_BLACK);
+     lcd.drawSprite(_x,_y,_width,_height,(int*)Battleshipp);
 }
      
 void Battleship::update(Direction d,float mag) 
--- a/StarcraftEngine/StarcraftEngine.cpp	Thu May 14 05:21:50 2020 +0000
+++ b/StarcraftEngine/StarcraftEngine.cpp	Thu May 14 06:30:39 2020 +0000
@@ -102,6 +102,8 @@
           (Swarm_pos.y >= HEIGHT - 1) 
         )   {                 
          _Battleship.minus_life();
+         Swarm_pos.x = rand() % 64;
+         Swarm_pos.y = 2;
          pad.tone(800.0,0.1);  //  Audio feedback 
      }
      
@@ -122,6 +124,8 @@
           (Boss_pos.y >= HEIGHT - 1) 
         )   {                 
          _Battleship.minus_life();
+         Boss_pos.x = rand() % 65;
+         Boss_pos.y = 2;
          pad.tone(800.0,0.1);  //  Audio feedback 
      }
      
@@ -144,9 +148,11 @@
      if ((Acid_pos.x >= Battleship_pos.x)&&
          (Acid_pos.x <= Battleship_pos.x + 6)&&
          (Acid_pos.y + 3 >= Battleship_pos.y)&&
-         (Acid_pos.y <= Battleship_pos.y + 3))
+         (Acid_pos.y <= Battleship_pos.y + 4))
      {
          _Battleship.minus_life();
+         Acid_pos.x = Boss_pos.x + 3;
+         Acid_pos.y = Boss_pos.y + 5; 
          pad.tone(800.0,0.1);  //  Audio feedback 
      }
      
@@ -226,9 +232,15 @@
      int Battleship_life = _Battleship.get_life();
      
      // print to LCD 
-     char buffer[14];
-     sprintf(buffer,"%2d",Battleship_score);
-     lcd.printString(buffer,WIDTH/2 - 20,1);  // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
+     char buffer1[14];
+     sprintf(buffer1,"%2d",Battleship_score);
+     lcd.printString("S",5,1);
+     lcd.printString(buffer1,10,1);  // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
+     
+     char buffer2[14];
+    sprintf(buffer2,"%2d",Battleship_life);
+    lcd.printString("L",WIDTH - 25,1);
+    lcd.printString(buffer2,WIDTH - 20,1);
 } 
  
  
--- a/mian.cpp	Thu May 14 05:21:50 2020 +0000
+++ b/mian.cpp	Thu May 14 06:30:39 2020 +0000
@@ -5,7 +5,7 @@
 Name: Haoyan Zhang
 Username: el17h2z
 Student ID Number: 201199698
-Date: 02/05/2020
+Date: 14/05/2020
  */ 
  
  ///////// pre-processor directives ////////
@@ -14,8 +14,8 @@
 #include "Gamepad.h"
 #include "StarcraftEngine.h"
 
-#define BATTLESHIP_HEIGHT 3
-#define BATTLESHIP_WIDTH 6
+#define BATTLESHIP_HEIGHT 6
+#define BATTLESHIP_WIDTH 4
 #define LASER_HEIGHT 2
 #define LASER_WIDTH 1
 #define SWARM_HEIGHT 6