Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.
Dependencies: mbed
Diff: Spaceship/Spaceship.cpp
- Revision:
- 141:02858e82c9cc
- Parent:
- 140:e389918735a7
- Child:
- 142:92f277a3e7e6
--- a/Spaceship/Spaceship.cpp Thu May 09 06:23:33 2019 +0000 +++ b/Spaceship/Spaceship.cpp Thu May 09 06:46:27 2019 +0000 @@ -34,43 +34,48 @@ _y_spaceship-=2; // the position of the spaceship at y-coordiante decrement by two -// printf("North\n"); - } else if(d==S) { +// printf("North\n"); //printf statment. + } else if(d==S) { // else if condition to check if the joystic's direction moves to the south - _y_spaceship+=2; - // printf("North\n"); + _y_spaceship+=2; // the position of the spaceship at y-coordiante increment by two + + // printf("North\n"); //printf statment } - if(_y_spaceship>=30) { - _y_spaceship=30; + if(_y_spaceship>=30) { //if statment to check the position of the spaceship at y_cooridante. + _y_spaceship=30; // y_cooridante of the spaceship equals 30 + //printif("alien at y_cooridante equal 30\n") // printif statment } else if(_y_spaceship<=0) { _y_spaceship=0; } } -int Spaceship::get_pos_x() +int Spaceship::get_pos_x() // to get the position of the spaceship at x_cooridante. { - return _x_spaceship; + return _x_spaceship; // return the value of x_corridante of the spaceship in integer. } -int Spaceship::get_pos_y() +int Spaceship::get_pos_y()//function to get the position of the alien at y_cooridante. { - return _y_spaceship; + return _y_spaceship; // return the value of y_corridante of the spaceship in integer. } +//void function to set the position of the spaceship in x-cooridante and y_cooridante. void Spaceship::set_pos(int x, int y) { - _x_spaceship = x; - _y_spaceship = y; + _x_spaceship = x; //the position of the spaceship at x-coordniate is equal to x. + _y_spaceship = y; //the position of the spaceship at y-coordniate is equal to y. } void Spaceship::add_score() { - _score++; + _score++; // increment the scores by 1. + //printf("scores increament by 1\n") } int Spaceship::get_score() { - return _score; + return _score; //return the numbers of the scores which achived by the spaceship. + //printf("returned scores\n") } \ No newline at end of file