Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
alexliu0812
Date:
Mon May 18 02:46:39 2020 +0000
Parent:
9:50470a40d213
Commit message:
Final Submission. I have read and agreed with Statement of Academic Integrity.

Changed in this revision

Block/Block.cpp Show annotated file Show diff for this revision Revisions of this file
Character/Character.cpp Show annotated file Show diff for this revision Revisions of this file
DodgeEngine/DodgeEngine.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Block/Block.cpp	Mon May 18 02:31:16 2020 +0000
+++ b/Block/Block.cpp	Mon May 18 02:46:39 2020 +0000
@@ -4,7 +4,7 @@
 Block::~Block(){}
 
 
-
+//initiate the position of the block
 void Block::blockinit(int x1up, int y1up, int x1down, int y1down, int x2up, int y2up, int x2down, int y2down){
     x1_up = x1up;
     y1_up = y1up;
@@ -17,11 +17,13 @@
     score = 0;
 }
 
+//draw the upper and lower walls
 void Block::draw_block(N5110 &lcd){
     lcd.drawLine(x1_up, y1_up, x1_down, y1_down,1);
     lcd.drawLine(x2_up, y2_up, x2_down, y2_down,1);
 }
 
+//level 1, the movenment of the walls
 void Block::blockupgrate(){
     
     if(x1_up < 1){
@@ -40,6 +42,7 @@
     }
 }
 
+//level 2, the movemnet of the walls
 void Block::blockupgrate2(){
     
     if(x1_up < 1){
@@ -58,6 +61,7 @@
     }
 }
 
+//level 3, the movement of the walls
 void Block::blockupgrate3(){
     
     if(x1_up < 1){
@@ -76,6 +80,11 @@
     }
 }
 
+//the movement of the y posiition of the walls
+//which means the space that character can pass
+//10 times is a period
+//whcih means in each level, the position is the same
+//for example, 1.1 = 2.1 = 3.1 = 4.1
 void Block::y_update(){
      
         int updatescore;
@@ -122,7 +131,7 @@
         }
 }
     
-
+//level 4, the movement of the walls
 void Block::blockupgrate4(){
     
     if(x1_up < 1){
@@ -141,30 +150,36 @@
     }
 }
 
+//the vector to get the upper coordinates of upper wall
 Vector2D Block::getposition1(){
     Vector2D p1 = {x1_up, y1_up};
     return p1;
 }
 
+//the vector to get the lower coordinates of upper wall
 Vector2D Block::getposition2(){
     Vector2D p2 = {x1_down, y1_down};
     return p2;
 }
 
+//the vector to get the upper coordinates of lower wall
 Vector2D Block::getposition3(){
     Vector2D p3 = {x2_up, y2_up};
     return p3;
 }
 
+//the vector to get the lower coordinates of lower wall
 Vector2D Block::getposition4(){
     Vector2D p4 = {x2_down, y2_down};
     return p4;
 }
 
+//function to add score by 1
 void Block::add_score(){
     score = score + 1;
 }
 
+//get the score
 int Block::get_score(){
     return score;
 }
--- a/Character/Character.cpp	Mon May 18 02:31:16 2020 +0000
+++ b/Character/Character.cpp	Mon May 18 02:46:39 2020 +0000
@@ -10,6 +10,7 @@
     chary = many;
 }
 
+//draw the character
 void Character::draw(N5110 &lcd){
     const int user[11][12] = {
     {0,0,0,0,0,0,0,0,0,0,0,0},
@@ -28,16 +29,19 @@
     lcd.drawSprite(charx,chary,11,12,(int *)user);
 }
 
+//hold A to move up the character
 void Character::move_up(Gamepad &pad){
     if(pad.A_held()== true){
         chary = chary - 5;
     }
 }
 
+//the character will drop downwards because of gravity
 void Character::move_down(){
     chary = chary + 3;
 }
 
+//check if the character has reach the boundry
 void Character::boundry(){
     //upper boundry
     if(chary < 0){
@@ -50,6 +54,7 @@
     }
 }
 
+//get the position of the character
 Vector2D Character::get_char_position(){
     Vector2D p = {charx, chary};
     return p;
--- a/DodgeEngine/DodgeEngine.cpp	Mon May 18 02:31:16 2020 +0000
+++ b/DodgeEngine/DodgeEngine.cpp	Mon May 18 02:46:39 2020 +0000
@@ -6,12 +6,14 @@
 
 void DodgeEngine::init(int x1up, int y1up, int x1down, int y1down, int x2up, int y2up, int x2down, int y2down, int manx, int many){
     
+    //initiate the block and character
     block.blockinit(x1up, y1up, x1down, y1down, x2up, y2up,x2down,y2down);
     character.charinit(manx, many);
 }
 
 void DodgeEngine::charactermove(N5110 &lcd,Gamepad &pad){
     
+    //control the movement and check for boundry
     character.move_up(pad);
     character.move_down();
     character.boundry();
@@ -21,6 +23,7 @@
 
 void DodgeEngine::blockmove(N5110 &lcd){
     
+    //control the movement of the block
     block.draw_block(lcd);
        
 }
@@ -28,17 +31,19 @@
 void DodgeEngine::dodgeupdate(N5110 &lcd, Gamepad &pad,int x1up, int y1up, int x1down, int y1down, int x2up, int y2up, int x2down, int y2down, int manx, int many){
     
     
+    //check if the character has collide with the walls first
     check_crash(lcd,pad,x1up, y1up, x1down, y1down, x2up, y2up,x2down,y2down,manx, many);
     show_score(lcd);
     
     int updatescore;
     updatescore = block.get_score();
     
+    //check if the player has pass the game
     if(updatescore > 39){
         pass_game(lcd,pad);
     }
         
-    
+    //update levels by score
     if(updatescore > 9 && updatescore < 20){
         //int test1 = 1;
         block.blockupgrate2();
@@ -148,7 +153,8 @@
     init(x1up, y1up, x1down, y1down, x2up, y2up,x2down,y2down,manx, many);
     
 }
-    
+
+//show the score on the top left corner on the lcd screen    
 void DodgeEngine::show_score(N5110 &lcd){
     
     int showscore = block.get_score();
--- a/main.cpp	Mon May 18 02:31:16 2020 +0000
+++ b/main.cpp	Mon May 18 02:46:39 2020 +0000
@@ -53,6 +53,7 @@
     pad.leds_off();
     wait(1.0f/fps);
     
+    //initate
     dodge.init(x1up, y1up, x1down, y1down, x2up, y2up,x2down,y2down, manx, many);
     while (1) {
         refreshing();