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:
- 140:e389918735a7
- Parent:
- 139:c46a2cef7e09
- Child:
- 141:02858e82c9cc
--- a/Spaceship/Spaceship.cpp Thu May 09 05:50:57 2019 +0000 +++ b/Spaceship/Spaceship.cpp Thu May 09 06:23:33 2019 +0000 @@ -30,26 +30,23 @@ { _speed_spaceship = int(mag*10.0f); - if(d==N){ - - _y_spaceship-=2; - - // printf("North\n"); - } - else - if(d==S){ - // printf("North\n"); - _y_spaceship+=2; + if(d==N) { //if statment to check if the joystic's direction moves to the north + + _y_spaceship-=2; // the position of the spaceship at y-coordiante decrement by two - } +// printf("North\n"); + } else if(d==S) { + + _y_spaceship+=2; + // printf("North\n"); - if(_y_spaceship>=30){ - _y_spaceship=30; - } - else - if(_y_spaceship<=0){ - _y_spaceship=0; - } + } + + if(_y_spaceship>=30) { + _y_spaceship=30; + } else if(_y_spaceship<=0) { + _y_spaceship=0; + } }